mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-12 23:23:20 +00:00
tests: add more empty content diff samples
This commit is contained in:
parent
8b222e4038
commit
73e4daf5ce
1 changed files with 42 additions and 1 deletions
|
@ -970,9 +970,50 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_single_empty_input() {
|
fn test_diff_some_empty_inputs() {
|
||||||
|
// All empty
|
||||||
let diff = Diff::default_refinement([""]);
|
let diff = Diff::default_refinement([""]);
|
||||||
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
||||||
|
let diff = Diff::default_refinement(["", ""]);
|
||||||
|
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
||||||
|
let diff = Diff::default_refinement(["", "", ""]);
|
||||||
|
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
||||||
|
|
||||||
|
// One empty
|
||||||
|
let diff = Diff::default_refinement(["a b", ""]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["a b", ""])]
|
||||||
|
);
|
||||||
|
let diff = Diff::default_refinement(["", "a b"]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["", "a b"])]
|
||||||
|
);
|
||||||
|
|
||||||
|
// One empty, two match
|
||||||
|
let diff = Diff::default_refinement(["a b", "", "a b"]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["a b", "", "a b"])]
|
||||||
|
);
|
||||||
|
let diff = Diff::default_refinement(["", "a b", "a b"]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["", "a b", "a b"])]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Two empty, one differs
|
||||||
|
let diff = Diff::default_refinement(["a b", "", ""]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["a b", "", ""])]
|
||||||
|
);
|
||||||
|
let diff = Diff::default_refinement(["", "a b", ""]);
|
||||||
|
assert_eq!(
|
||||||
|
diff.hunks().collect_vec(),
|
||||||
|
vec![DiffHunk::different(["", "a b", ""])]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue