]> git.lizzy.rs Git - rust.git/commitdiff
Add tests for #606.
authorUtkarsh Kukreti <utkarshkukreti@gmail.com>
Mon, 28 Dec 2015 11:53:34 +0000 (17:23 +0530)
committerUtkarsh Kukreti <utkarshkukreti@gmail.com>
Mon, 28 Dec 2015 11:53:34 +0000 (17:23 +0530)
src/rustfmt_diff.rs
tests/system.rs

index 8c20b8f5a0f0a68d7dc7a9f5be65e61af8ce56bc..4bb858a6b3079049ddb11b931e5e4df9e3c46cd3 100644 (file)
@@ -2,12 +2,14 @@
 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>,
index 6d3c817256cae7443c0260d4c1ffa212ff0165eb..d6f1ba806f53d8a2699e3cd441617fce6ef2fb1b 100644 (file)
@@ -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())],
+                    }]);
+}