forked from mirrors/jj
tests: use diff::diff() instead of Diff::default_refinement()
Diff::default_refinement() will be removed.
This commit is contained in:
parent
db0a4bccc5
commit
864dd73856
1 changed files with 13 additions and 32 deletions
|
@ -976,62 +976,45 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_single_input() {
|
fn test_diff_single_input() {
|
||||||
let diff = Diff::default_refinement(["abc"]);
|
assert_eq!(diff(["abc"]), vec![DiffHunk::matching("abc")]);
|
||||||
assert_eq!(diff.hunks().collect_vec(), vec![DiffHunk::matching("abc")]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_some_empty_inputs() {
|
fn test_diff_some_empty_inputs() {
|
||||||
// All empty
|
// All empty
|
||||||
let diff = Diff::default_refinement([""]);
|
assert_eq!(diff([""]), vec![]);
|
||||||
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
assert_eq!(diff(["", ""]), vec![]);
|
||||||
let diff = Diff::default_refinement(["", ""]);
|
assert_eq!(diff(["", "", ""]), vec![]);
|
||||||
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
|
||||||
let diff = Diff::default_refinement(["", "", ""]);
|
|
||||||
assert_eq!(diff.hunks().collect_vec(), vec![]);
|
|
||||||
|
|
||||||
// One empty
|
// One empty
|
||||||
let diff = Diff::default_refinement(["a b", ""]);
|
assert_eq!(diff(["a b", ""]), vec![DiffHunk::different(["a b", ""])]);
|
||||||
assert_eq!(
|
assert_eq!(diff(["", "a b"]), vec![DiffHunk::different(["", "a b"])]);
|
||||||
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
|
// One empty, two match
|
||||||
let diff = Diff::default_refinement(["a b", "", "a b"]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["a b", "", "a b"]),
|
||||||
vec![DiffHunk::different(["a b", "", "a b"])]
|
vec![DiffHunk::different(["a b", "", "a b"])]
|
||||||
);
|
);
|
||||||
let diff = Diff::default_refinement(["", "a b", "a b"]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["", "a b", "a b"]),
|
||||||
vec![DiffHunk::different(["", "a b", "a b"])]
|
vec![DiffHunk::different(["", "a b", "a b"])]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Two empty, one differs
|
// Two empty, one differs
|
||||||
let diff = Diff::default_refinement(["a b", "", ""]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["a b", "", ""]),
|
||||||
vec![DiffHunk::different(["a b", "", ""])]
|
vec![DiffHunk::different(["a b", "", ""])]
|
||||||
);
|
);
|
||||||
let diff = Diff::default_refinement(["", "a b", ""]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["", "a b", ""]),
|
||||||
vec![DiffHunk::different(["", "a b", ""])]
|
vec![DiffHunk::different(["", "a b", ""])]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_two_inputs_one_different() {
|
fn test_diff_two_inputs_one_different() {
|
||||||
let diff = Diff::default_refinement(["a b c", "a X c"]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["a b c", "a X c"]),
|
||||||
vec![
|
vec![
|
||||||
DiffHunk::matching("a "),
|
DiffHunk::matching("a "),
|
||||||
DiffHunk::different(["b", "X"]),
|
DiffHunk::different(["b", "X"]),
|
||||||
|
@ -1042,9 +1025,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_multiple_inputs_one_different() {
|
fn test_diff_multiple_inputs_one_different() {
|
||||||
let diff = Diff::default_refinement(["a b c", "a X c", "a b c"]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["a b c", "a X c", "a b c"]),
|
||||||
vec![
|
vec![
|
||||||
DiffHunk::matching("a "),
|
DiffHunk::matching("a "),
|
||||||
DiffHunk::different(["b", "X", "b"]),
|
DiffHunk::different(["b", "X", "b"]),
|
||||||
|
@ -1055,9 +1037,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_diff_multiple_inputs_all_different() {
|
fn test_diff_multiple_inputs_all_different() {
|
||||||
let diff = Diff::default_refinement(["a b c", "a X c", "a c X"]);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
diff.hunks().collect_vec(),
|
diff(["a b c", "a X c", "a c X"]),
|
||||||
vec![
|
vec![
|
||||||
DiffHunk::matching("a "),
|
DiffHunk::matching("a "),
|
||||||
DiffHunk::different(["b ", "X ", ""]),
|
DiffHunk::different(["b ", "X ", ""]),
|
||||||
|
|
Loading…
Reference in a new issue