本文整理汇总了C#中nicTest.diff_match_patchTest.diff_cleanupMerge方法的典型用法代码示例。如果您正苦于以下问题:C# diff_match_patchTest.diff_cleanupMerge方法的具体用法?C# diff_match_patchTest.diff_cleanupMerge怎么用?C# diff_match_patchTest.diff_cleanupMerge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nicTest.diff_match_patchTest
的用法示例。
在下文中一共展示了diff_match_patchTest.diff_cleanupMerge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: diff_cleanupMergeTest
public void diff_cleanupMergeTest()
{
var dmp = new diff_match_patchTest();
// Cleanup a messy diff.
// Null case.
var diffs = new List<Diff>();
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>(), diffs);
// No change case.
diffs = new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Delete, "b"), new Diff(Operation.Insert, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Delete, "b"), new Diff(Operation.Insert, "c")}, diffs);
// Merge equalities.
diffs = new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Equal, "b"), new Diff(Operation.Equal, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "abc")}, diffs);
// Merge deletions.
diffs = new List<Diff>{new Diff(Operation.Delete, "a"), new Diff(Operation.Delete, "b"), new Diff(Operation.Delete, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Delete, "abc")}, diffs);
// Merge insertions.
diffs = new List<Diff>{new Diff(Operation.Insert, "a"), new Diff(Operation.Insert, "b"), new Diff(Operation.Insert, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Insert, "abc")}, diffs);
// Merge interweave.
diffs = new List<Diff>{new Diff(Operation.Delete, "a"), new Diff(Operation.Insert, "b"), new Diff(Operation.Delete, "c"), new Diff(Operation.Insert, "d"), new Diff(Operation.Equal, "e"), new Diff(Operation.Equal, "f")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Delete, "ac"), new Diff(Operation.Insert, "bd"), new Diff(Operation.Equal, "ef")}, diffs);
// Prefix and suffix detection.
diffs = new List<Diff>{new Diff(Operation.Delete, "a"), new Diff(Operation.Insert, "abc"), new Diff(Operation.Delete, "dc")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Delete, "d"), new Diff(Operation.Insert, "b"), new Diff(Operation.Equal, "c")}, diffs);
// Prefix and suffix detection with equalities.
diffs = new List<Diff>{new Diff(Operation.Equal, "x"), new Diff(Operation.Delete, "a"), new Diff(Operation.Insert, "abc"), new Diff(Operation.Delete, "dc"), new Diff(Operation.Equal, "y")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "xa"), new Diff(Operation.Delete, "d"), new Diff(Operation.Insert, "b"), new Diff(Operation.Equal, "cy")}, diffs);
// Slide edit left.
diffs = new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Insert, "ba"), new Diff(Operation.Equal, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Insert, "ab"), new Diff(Operation.Equal, "ac")}, diffs);
// Slide edit right.
diffs = new List<Diff>{new Diff(Operation.Equal, "c"), new Diff(Operation.Insert, "ab"), new Diff(Operation.Equal, "a")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "ca"), new Diff(Operation.Insert, "ba")}, diffs);
// Slide edit left recursive.
diffs = new List<Diff>{new Diff(Operation.Equal, "a"), new Diff(Operation.Delete, "b"), new Diff(Operation.Equal, "c"), new Diff(Operation.Delete, "ac"), new Diff(Operation.Equal, "x")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Delete, "abc"), new Diff(Operation.Equal, "acx")}, diffs);
// Slide edit right recursive.
diffs = new List<Diff>{new Diff(Operation.Equal, "x"), new Diff(Operation.Delete, "ca"), new Diff(Operation.Equal, "c"), new Diff(Operation.Delete, "b"), new Diff(Operation.Equal, "a")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.Equal, "xca"), new Diff(Operation.Delete, "cba")}, diffs);
}
示例2: diff_cleanupMergeTest
public void diff_cleanupMergeTest()
{
diff_match_patchTest dmp = new diff_match_patchTest();
// Cleanup a messy diff.
List<Diff> diffs = new List<Diff>();
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>(), diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.DELETE, "b"), new Diff(Operation.INSERT, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.DELETE, "b"), new Diff(Operation.INSERT, "c")}, diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.EQUAL, "b"), new Diff(Operation.EQUAL, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.EQUAL, "abc")}, diffs);
diffs = new List<Diff>{new Diff(Operation.DELETE, "a"), new Diff(Operation.DELETE, "b"), new Diff(Operation.DELETE, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.DELETE, "abc")}, diffs);
diffs = new List<Diff>{new Diff(Operation.INSERT, "a"), new Diff(Operation.INSERT, "b"), new Diff(Operation.INSERT, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.INSERT, "abc")}, diffs);
diffs = new List<Diff>{new Diff(Operation.DELETE, "a"), new Diff(Operation.INSERT, "b"), new Diff(Operation.DELETE, "c"), new Diff(Operation.INSERT, "d"), new Diff(Operation.EQUAL, "e"), new Diff(Operation.EQUAL, "f")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.DELETE, "ac"), new Diff(Operation.INSERT, "bd"), new Diff(Operation.EQUAL, "ef")}, diffs);
diffs = new List<Diff>{new Diff(Operation.DELETE, "a"), new Diff(Operation.INSERT, "abc"), new Diff(Operation.DELETE, "dc")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.DELETE, "d"), new Diff(Operation.INSERT, "b"), new Diff(Operation.EQUAL, "c")}, diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.INSERT, "ba"), new Diff(Operation.EQUAL, "c")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.INSERT, "ab"), new Diff(Operation.EQUAL, "ac")}, diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "c"), new Diff(Operation.INSERT, "ab"), new Diff(Operation.EQUAL, "a")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.EQUAL, "ca"), new Diff(Operation.INSERT, "ba")}, diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "a"), new Diff(Operation.DELETE, "b"), new Diff(Operation.EQUAL, "c"), new Diff(Operation.DELETE, "ac"), new Diff(Operation.EQUAL, "x")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.DELETE, "abc"), new Diff(Operation.EQUAL, "acx")}, diffs);
diffs = new List<Diff>{new Diff(Operation.EQUAL, "x"), new Diff(Operation.DELETE, "ca"), new Diff(Operation.EQUAL, "c"), new Diff(Operation.DELETE, "b"), new Diff(Operation.EQUAL, "a")};
dmp.diff_cleanupMerge(diffs);
CollectionAssert.AreEqual(new List<Diff>{new Diff(Operation.EQUAL, "xca"), new Diff(Operation.DELETE, "cba")}, diffs);
}