@@ -6,7 +6,7 @@ use expect_test::{expect, expect_file};
66
77use crate :: intern:: InternedInput ;
88use crate :: sink:: Counter ;
9- use crate :: { diff, Algorithm , UnifiedDiffBuilder } ;
9+ use crate :: { diff, unified_diff :: ContextSize , Algorithm , UnifiedDiffBuilder } ;
1010
1111#[ test]
1212fn replace ( ) {
@@ -28,7 +28,11 @@ fn foo() -> Bar{
2828 let input = InternedInput :: new ( before, after) ;
2929 for algorithm in Algorithm :: ALL {
3030 println ! ( "{algorithm:?}" ) ;
31- let diff = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, None ) ) ;
31+ let diff = diff (
32+ algorithm,
33+ & input,
34+ UnifiedDiffBuilder :: new ( & input, ContextSize :: default ( ) ) ,
35+ ) ;
3236 expect ! [ [ r#"
3337 @@ -1,5 +1,8 @@
3438 +const TEST: i32 = 0;
@@ -55,7 +59,11 @@ fn identical_files() {
5559 for algorithm in Algorithm :: ALL {
5660 println ! ( "{algorithm:?}" ) ;
5761 let input = InternedInput :: new ( file, file) ;
58- let diff = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, None ) ) ;
62+ let diff = diff (
63+ algorithm,
64+ & input,
65+ UnifiedDiffBuilder :: new ( & input, ContextSize :: default ( ) ) ,
66+ ) ;
5967 assert_eq ! ( diff, "" ) ;
6068 }
6169}
@@ -76,7 +84,11 @@ fn simple_insert() {
7684 let mut input = InternedInput :: new ( before, after) ;
7785 for algorithm in Algorithm :: ALL {
7886 println ! ( "{algorithm:?}" ) ;
79- let res = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, None ) ) ;
87+ let res = diff (
88+ algorithm,
89+ & input,
90+ UnifiedDiffBuilder :: new ( & input, ContextSize :: default ( ) ) ,
91+ ) ;
8092 expect ! [ [ r#"
8193 @@ -1,4 +1,5 @@
8294 fn foo() -> Bar{
@@ -89,7 +101,11 @@ fn simple_insert() {
89101
90102 swap ( & mut input. before , & mut input. after ) ;
91103
92- let res = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, None ) ) ;
104+ let res = diff (
105+ algorithm,
106+ & input,
107+ UnifiedDiffBuilder :: new ( & input, ContextSize :: default ( ) ) ,
108+ ) ;
93109 expect ! [ [ r#"
94110 @@ -1,5 +1,4 @@
95111 fn foo() -> Bar{
@@ -129,11 +145,19 @@ fn hand_checked_udiffs() {
129145 let before = read_to_string ( path_before) . unwrap ( ) ;
130146 let after = read_to_string ( path_after) . unwrap ( ) ;
131147 let input = InternedInput :: new ( & * before, & * after) ;
132- let diff_res = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, None ) ) ;
148+ let diff_res = diff (
149+ algorithm,
150+ & input,
151+ UnifiedDiffBuilder :: new ( & input, ContextSize :: default ( ) ) ,
152+ ) ;
133153 expect_file ! [ path_diff] . assert_eq ( & diff_res) ;
134154 // test with a context of 5 lines
135155 let path_diff = test_dir. join ( format ! ( "{file}.{algorithm:?}_ctx5.diff" ) ) ;
136- let diff_res = diff ( algorithm, & input, UnifiedDiffBuilder :: new ( & input, Some ( 5 ) ) ) ;
156+ let diff_res = diff (
157+ algorithm,
158+ & input,
159+ UnifiedDiffBuilder :: new ( & input, ContextSize :: symmetrical ( 5 ) ) ,
160+ ) ;
137161 expect_file ! [ path_diff] . assert_eq ( & diff_res) ;
138162 }
139163}
0 commit comments