about summary refs log tree commit diff
path: root/src/rustfmt_diff.rs
diff options
context:
space:
mode:
authorChris Emerson <github@mail.nosreme.org>2017-10-19 20:49:33 +0100
committerChris Emerson <github@mail.nosreme.org>2017-10-19 20:50:55 +0100
commit88f02975a1064e91ffe3e28efe1b744a11a39209 (patch)
tree843af3f2aa73354b270c74c3af47832e6cb4f564 /src/rustfmt_diff.rs
parent560b0541470345277a6b0d7c721ae91c0bfdd4ff (diff)
Add a simple passing test for diffs.
Diffstat (limited to 'src/rustfmt_diff.rs')
-rw-r--r--src/rustfmt_diff.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs
index 3fb22865385..6884e39141d 100644
--- a/src/rustfmt_diff.rs
+++ b/src/rustfmt_diff.rs
@@ -162,3 +162,23 @@ where
         }
     }
 }
+
+#[cfg(test)]
+mod test {
+    use super::{make_diff,Mismatch};
+    use super::DiffLine::*;
+
+    #[test]
+    fn simple_diff() {
+        let src = "one\ntwo\nthree\nfour\nfive\n";
+        let dest= "one\ntwo\ntrois\nfour\nfive\n";
+        let diff = make_diff(src, dest, 1);
+        assert_eq!(diff, vec![Mismatch { line_number: 2,
+                                         lines: vec![
+                                             Context("two".into()),
+                                             Resulting("three".into()),
+                                             Expected("trois".into()),
+                                             Context("four".into()),
+                                         ] }]);
+    }
+}
\ No newline at end of file