From 6c1c81bbced8c6d98701ea70845f1626ac703c31 Mon Sep 17 00:00:00 2001 From: Chris Emerson Date: Thu, 19 Oct 2017 23:03:27 +0100 Subject: [PATCH] Add a test for two nearby chunks (with context). --- src/rustfmt_diff.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs index 644ad7ceeac..fa3c6305ed8 100644 --- a/src/rustfmt_diff.rs +++ b/src/rustfmt_diff.rs @@ -182,6 +182,26 @@ mod test { ] }]); } + #[test] + fn diff_simple2() { + let src = "one\ntwo\nthree\nfour\nfive\nsix\nseven\n"; + let dest= "one\ntwo\ntrois\nfour\ncinq\nsix\nseven\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()), + ] }, + Mismatch { line_number: 5, + lines: vec![ + Resulting("five".into()), + Expected("cinq".into()), + Context("six".into()), + ] }]); + } + #[test] fn diff_zerocontext() { let src = "one\ntwo\nthree\nfour\nfive\n";