Add tests for #606.
This commit is contained in:
parent
6a12818c23
commit
15e6b7d335
@ -2,12 +2,14 @@ use std::collections::VecDeque;
|
||||
use diff;
|
||||
use term;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DiffLine {
|
||||
Context(String),
|
||||
Expected(String),
|
||||
Resulting(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Mismatch {
|
||||
pub line_number: u32,
|
||||
pub lines: Vec<DiffLine>,
|
||||
|
@ -273,3 +273,17 @@ fn get_target(file_name: &str, target: Option<&str>, write_mode: WriteMode) -> S
|
||||
file_name.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rustfmt_diff_make_diff_tests() {
|
||||
let diff = make_diff("a\nb\nc\nd", "a\ne\nc\nd", 3);
|
||||
assert_eq!(diff,
|
||||
vec![Mismatch {
|
||||
line_number: 1,
|
||||
lines: vec![DiffLine::Context("a".into()),
|
||||
DiffLine::Resulting("b".into()),
|
||||
DiffLine::Expected("e".into()),
|
||||
DiffLine::Context("c".into()),
|
||||
DiffLine::Context("d".into())],
|
||||
}]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user