@@ -6,7 +6,7 @@ use expect_test::{expect, expect_file};
6
6
7
7
use crate :: intern:: InternedInput ;
8
8
use crate :: sink:: Counter ;
9
- use crate :: { diff, Algorithm , UnifiedDiffBuilder } ;
9
+ use crate :: { diff, unified_diff :: ContextSize , Algorithm , UnifiedDiffBuilder } ;
10
10
11
11
#[ test]
12
12
fn replace ( ) {
@@ -28,7 +28,11 @@ fn foo() -> Bar{
28
28
let input = InternedInput :: new ( before, after) ;
29
29
for algorithm in Algorithm :: ALL {
30
30
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
+ ) ;
32
36
expect ! [ [ r#"
33
37
@@ -1,5 +1,8 @@
34
38
+const TEST: i32 = 0;
@@ -55,7 +59,11 @@ fn identical_files() {
55
59
for algorithm in Algorithm :: ALL {
56
60
println ! ( "{algorithm:?}" ) ;
57
61
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
+ ) ;
59
67
assert_eq ! ( diff, "" ) ;
60
68
}
61
69
}
@@ -76,7 +84,11 @@ fn simple_insert() {
76
84
let mut input = InternedInput :: new ( before, after) ;
77
85
for algorithm in Algorithm :: ALL {
78
86
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
+ ) ;
80
92
expect ! [ [ r#"
81
93
@@ -1,4 +1,5 @@
82
94
fn foo() -> Bar{
@@ -89,7 +101,11 @@ fn simple_insert() {
89
101
90
102
swap ( & mut input. before , & mut input. after ) ;
91
103
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
+ ) ;
93
109
expect ! [ [ r#"
94
110
@@ -1,5 +1,4 @@
95
111
fn foo() -> Bar{
@@ -129,11 +145,19 @@ fn hand_checked_udiffs() {
129
145
let before = read_to_string ( path_before) . unwrap ( ) ;
130
146
let after = read_to_string ( path_after) . unwrap ( ) ;
131
147
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
+ ) ;
133
153
expect_file ! [ path_diff] . assert_eq ( & diff_res) ;
134
154
// test with a context of 5 lines
135
155
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
+ ) ;
137
161
expect_file ! [ path_diff] . assert_eq ( & diff_res) ;
138
162
}
139
163
}
0 commit comments