Add test for trailing newline in diff.

Credits to @afshinm for most of the code.
This commit is contained in:
Utkarsh Kukreti 2017-11-17 20:46:17 +05:30
parent d0df53d833
commit d44d4a3fbc

View File

@ -234,4 +234,20 @@ mod test {
]
);
}
#[test]
fn diff_trailing_newline() {
let src = "one\ntwo\nthree\nfour\nfive";
let dest = "one\ntwo\nthree\nfour\nfive\n";
let diff = make_diff(src, dest, 1);
assert_eq!(
diff,
vec![
Mismatch {
line_number: 5,
lines: vec![Context("five".into()), Expected("".into())],
},
]
);
}
}