Skip to content

Commit

Permalink
Add tests for #606.
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshkukreti committed Dec 28, 2015
1 parent 6a12818 commit 15e6b7d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rustfmt_diff.rs
Expand Up @@ -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>,
Expand Down
14 changes: 14 additions & 0 deletions tests/system.rs
Expand Up @@ -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())],
}]);
}

0 comments on commit 15e6b7d

Please sign in to comment.