Skip to content

Commit

Permalink
Add test for trailing newline in diff.
Browse files Browse the repository at this point in the history
Credits to @afshinm for most of the code.
  • Loading branch information
utkarshkukreti committed Nov 17, 2017
1 parent d0df53d commit d44d4a3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/rustfmt_diff.rs
Expand Up @@ -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())],
},
]
);
}
}

0 comments on commit d44d4a3

Please sign in to comment.