Add context diff and tests for it

This commit is contained in:
Dima Kudosh
2016-02-28 19:14:11 +03:00
parent 0fa2c80be0
commit 3781894ffc
3 changed files with 85 additions and 2 deletions
+8
View File
@@ -109,5 +109,13 @@ fn test_unified_diff() {
let result = difflib::unified_diff(&first_text, &second_text, "Original", "Current",
"2005-01-26 23:30:50", "2010-04-02 10:20:52", 3, "").join("");
assert_eq!(result, "--- Original\t2005-01-26 23:30:50+++ Current\t2010-04-02 10:20:52@@ -1,4 +1,4 @@+zero one-two-three+tree four");
}
#[test]
fn test_context_diff() {
let first_text = "one two three four".split(" ").collect::<Vec<&str>>();
let second_text = "zero one tree four".split(" ").collect::<Vec<&str>>();
let result = difflib::context_diff(&first_text, &second_text, "Original", "Current",
"2005-01-26 23:30:50", "2010-04-02 10:20:52", 3, "").join("");
assert_eq!(result, "*** Original\t2005-01-26 23:30:50--- Current\t2010-04-02 10:20:52****************** 1,4 **** one! two! three four--- 1,4 ----+ zero one! tree four");
}