Use named snapshots for tests

This commit is contained in:
Armin Ronacher 2021-01-24 09:17:09 +01:00
parent 93ded2e62c
commit 18fff98d22
12 changed files with 271 additions and 201 deletions

View file

@ -185,26 +185,7 @@ fn test_diff() {
let mut d = crate::algorithms::Replace::new(crate::algorithms::Capture::new());
diff_slices(&mut d, a, b).unwrap();
insta::assert_debug_snapshot!(d.into_inner().ops(), @r###"
[
Equal {
old_index: 0,
new_index: 0,
len: 3,
},
Replace {
old_index: 3,
old_len: 1,
new_index: 3,
new_len: 1,
},
Equal {
old_index: 4,
new_index: 4,
len: 1,
},
]
"###);
insta::assert_debug_snapshot!(d.into_inner().ops());
}
#[test]
@ -214,32 +195,7 @@ fn test_contiguous() {
let mut d = crate::algorithms::Replace::new(crate::algorithms::Capture::new());
diff_slices(&mut d, a, b).unwrap();
insta::assert_debug_snapshot!(d.into_inner().ops(), @r###"
[
Equal {
old_index: 0,
new_index: 0,
len: 3,
},
Replace {
old_index: 3,
old_len: 2,
new_index: 3,
new_len: 2,
},
Equal {
old_index: 5,
new_index: 5,
len: 2,
},
Replace {
old_index: 7,
old_len: 1,
new_index: 7,
new_len: 1,
},
]
"###);
insta::assert_debug_snapshot!(d.into_inner().ops());
}
#[test]
@ -249,33 +205,5 @@ fn test_pat() {
let mut d = crate::algorithms::Capture::new();
diff_slices(&mut d, a, b).unwrap();
insta::assert_debug_snapshot!(d.ops(), @r###"
[
Equal {
old_index: 0,
new_index: 0,
len: 2,
},
Delete {
old_index: 2,
old_len: 1,
new_index: 2,
},
Equal {
old_index: 3,
new_index: 2,
len: 2,
},
Insert {
old_index: 5,
new_index: 4,
new_len: 1,
},
Insert {
old_index: 5,
new_index: 5,
new_len: 1,
},
]
"###);
insta::assert_debug_snapshot!(d.ops());
}