当前位置: 首页>>代码示例>>C#>>正文


C# diff_match_patchTest.diff_cleanupMerge方法代码示例

本文整理汇总了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);
        }
开发者ID:i-e-b,项目名称:DiffTools,代码行数:64,代码来源:DiffMatchPatchTest.cs

示例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);
        }
开发者ID:victorarias,项目名称:dojo-centro,代码行数:48,代码来源:DiffMatchPatchTest.cs


注:本文中的nicTest.diff_match_patchTest.diff_cleanupMerge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。