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


C# diff_match_patchTest.diff_cleanupSemantic方法代码示例

本文整理汇总了C#中nicTest.diff_match_patchTest.diff_cleanupSemantic方法的典型用法代码示例。如果您正苦于以下问题:C# diff_match_patchTest.diff_cleanupSemantic方法的具体用法?C# diff_match_patchTest.diff_cleanupSemantic怎么用?C# diff_match_patchTest.diff_cleanupSemantic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nicTest.diff_match_patchTest的用法示例。


在下文中一共展示了diff_match_patchTest.diff_cleanupSemantic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: diff_cleanupSemanticTest

        public void diff_cleanupSemanticTest()
        {
            diff_match_patchTest dmp = new diff_match_patchTest();
              // Cleanup semantically trivial equalities.
              // Null case.
              List<Diff> diffs = new List<Diff>();
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff>(), diffs);

              // No elimination #1.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "ab"),
              new Diff(Operation.INSERT, "cd"),
              new Diff(Operation.EQUAL, "12"),
              new Diff(Operation.DELETE, "e")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "ab"),
              new Diff(Operation.INSERT, "cd"),
              new Diff(Operation.EQUAL, "12"),
              new Diff(Operation.DELETE, "e")}, diffs);

              // No elimination #2.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "abc"),
              new Diff(Operation.INSERT, "ABC"),
              new Diff(Operation.EQUAL, "1234"),
              new Diff(Operation.DELETE, "wxyz")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "abc"),
              new Diff(Operation.INSERT, "ABC"),
              new Diff(Operation.EQUAL, "1234"),
              new Diff(Operation.DELETE, "wxyz")}, diffs);

              // Simple elimination.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "a"),
              new Diff(Operation.EQUAL, "b"),
              new Diff(Operation.DELETE, "c")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "abc"),
              new Diff(Operation.INSERT, "b")}, diffs);

              // Backpass elimination.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "ab"),
              new Diff(Operation.EQUAL, "cd"),
              new Diff(Operation.DELETE, "e"),
              new Diff(Operation.EQUAL, "f"),
              new Diff(Operation.INSERT, "g")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "abcdef"),
              new Diff(Operation.INSERT, "cdfg")}, diffs);

              // Multiple eliminations.
              diffs = new List<Diff> {
              new Diff(Operation.INSERT, "1"),
              new Diff(Operation.EQUAL, "A"),
              new Diff(Operation.DELETE, "B"),
              new Diff(Operation.INSERT, "2"),
              new Diff(Operation.EQUAL, "_"),
              new Diff(Operation.INSERT, "1"),
              new Diff(Operation.EQUAL, "A"),
              new Diff(Operation.DELETE, "B"),
              new Diff(Operation.INSERT, "2")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "AB_AB"),
              new Diff(Operation.INSERT, "1A2_1A2")}, diffs);

              // Word boundaries.
              diffs = new List<Diff> {
              new Diff(Operation.EQUAL, "The c"),
              new Diff(Operation.DELETE, "ow and the c"),
              new Diff(Operation.EQUAL, "at.")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.EQUAL, "The "),
              new Diff(Operation.DELETE, "cow and the "),
              new Diff(Operation.EQUAL, "cat.")}, diffs);

              // Overlap elimination #1.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "abcxx"),
              new Diff(Operation.INSERT, "xxdef")};
              dmp.diff_cleanupSemantic(diffs);
              CollectionAssert.AreEqual(new List<Diff> {
              new Diff(Operation.DELETE, "abc"),
              new Diff(Operation.EQUAL, "xx"),
              new Diff(Operation.INSERT, "def")}, diffs);

              // Overlap elimination #2.
              diffs = new List<Diff> {
              new Diff(Operation.DELETE, "abcxx"),
              new Diff(Operation.INSERT, "xxdef"),
              new Diff(Operation.DELETE, "ABCXX"),
              new Diff(Operation.INSERT, "XXDEF")};
//.........这里部分代码省略.........
开发者ID:rcatolino,项目名称:editor,代码行数:101,代码来源:DiffMatchPatchTest.cs

示例2: diff_cleanupSemanticTest

        public void diff_cleanupSemanticTest()
        {
            var dmp = new diff_match_patchTest();
            // Cleanup semantically trivial equalities.
            // Null case.
            var diffs = new List<Diff>();
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>(), diffs);

            // No elimination #1.
            diffs = new List<Diff>{
                new Diff(Operation.Delete, "ab"),
                new Diff(Operation.Insert, "cd"),
                new Diff(Operation.Equal, "12"),
                new Diff(Operation.Delete, "e")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Delete, "ab"),
                new Diff(Operation.Insert, "cd"),
                new Diff(Operation.Equal, "12"),
                new Diff(Operation.Delete, "e")
            }, diffs);

            // No elimination #2.
            diffs = new List<Diff>{
                new Diff(Operation.Delete, "abc"),
                new Diff(Operation.Insert, "ABC"),
                new Diff(Operation.Equal, "1234"),
                new Diff(Operation.Delete, "wxyz")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Delete, "abc"),
                new Diff(Operation.Insert, "ABC"),
                new Diff(Operation.Equal, "1234"),
                new Diff(Operation.Delete, "wxyz")
            }, diffs);

            // Simple elimination.
            diffs = new List<Diff>{
                new Diff(Operation.Delete, "a"),
                new Diff(Operation.Equal, "b"),
                new Diff(Operation.Delete, "c")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Delete, "abc"),
                new Diff(Operation.Insert, "b")
            }, diffs);

            // Backpass elimination.
            diffs = new List<Diff>{
                new Diff(Operation.Delete, "ab"),
                new Diff(Operation.Equal, "cd"),
                new Diff(Operation.Delete, "e"),
                new Diff(Operation.Equal, "f"),
                new Diff(Operation.Insert, "g")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Delete, "abcdef"),
                new Diff(Operation.Insert, "cdfg")
            }, diffs);

            // Multiple eliminations.
            diffs = new List<Diff>{
                new Diff(Operation.Insert, "1"),
                new Diff(Operation.Equal, "A"),
                new Diff(Operation.Delete, "B"),
                new Diff(Operation.Insert, "2"),
                new Diff(Operation.Equal, "_"),
                new Diff(Operation.Insert, "1"),
                new Diff(Operation.Equal, "A"),
                new Diff(Operation.Delete, "B"),
                new Diff(Operation.Insert, "2")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Delete, "AB_AB"),
                new Diff(Operation.Insert, "1A2_1A2")
            }, diffs);

            // Word boundaries.
            diffs = new List<Diff>{
                new Diff(Operation.Equal, "The c"),
                new Diff(Operation.Delete, "ow and the c"),
                new Diff(Operation.Equal, "at.")
            };
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.Equal, "The "),
                new Diff(Operation.Delete, "cow and the "),
                new Diff(Operation.Equal, "cat.")
            }, diffs);

            // No overlap elimination.
            diffs = new List<Diff>{
                new Diff(Operation.Delete, "abcxx"),
                new Diff(Operation.Insert, "xxdef")
//.........这里部分代码省略.........
开发者ID:i-e-b,项目名称:DiffTools,代码行数:101,代码来源:DiffMatchPatchTest.cs

示例3: diff_cleanupSemanticTest

        public void diff_cleanupSemanticTest()
        {
            diff_match_patchTest dmp = new diff_match_patchTest();
            // Cleanup semantically trivial equalities.
            List<Diff> diffs = new List<Diff>();
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>(), diffs);

            diffs = new List<Diff>{
                new Diff(Operation.DELETE, "a"),
                new Diff(Operation.INSERT, "b"),
                new Diff(Operation.EQUAL, "cd"),
                new Diff(Operation.DELETE, "e")};
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(
                new List<Diff>{
                    new Diff(Operation.DELETE, "a"),
                    new Diff(Operation.INSERT, "b"),
                    new Diff(Operation.EQUAL, "cd"),
                    new Diff(Operation.DELETE, "e")}, diffs);

            diffs = new List<Diff>{
                new Diff(Operation.DELETE, "a"),
                new Diff(Operation.EQUAL, "b"),
                new Diff(Operation.DELETE, "c")};
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(
                new List<Diff>{
                    new Diff(Operation.DELETE, "abc"),
                    new Diff(Operation.INSERT, "b")}, diffs);

            diffs = new List<Diff>{
                new Diff(Operation.DELETE, "ab"),
                new Diff(Operation.EQUAL, "cd"),
                new Diff(Operation.DELETE, "e"),
                new Diff(Operation.EQUAL, "f"),
                new Diff(Operation.INSERT, "g")};
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.DELETE, "abcdef"),
                new Diff(Operation.INSERT, "cdfg")}, diffs);

            diffs = new List<Diff>{
                new Diff(Operation.INSERT, "1"),
                new Diff(Operation.EQUAL, "A"),
                new Diff(Operation.DELETE, "B"),
                new Diff(Operation.INSERT, "2"),
                new Diff(Operation.EQUAL, "_"),
                new Diff(Operation.INSERT, "1"),
                new Diff(Operation.EQUAL, "A"),
                new Diff(Operation.DELETE, "B"),
                new Diff(Operation.INSERT, "2")};
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.DELETE, "AB_AB"),
                new Diff(Operation.INSERT, "1A2_1A2")}, diffs);

            diffs = new List<Diff>{
                new Diff(Operation.EQUAL, "The c"),
                new Diff(Operation.DELETE, "ow and the c"),
                new Diff(Operation.EQUAL, "at.")};
            dmp.diff_cleanupSemantic(diffs);
            CollectionAssert.AreEqual(new List<Diff>{
                new Diff(Operation.EQUAL, "The "),
                new Diff(Operation.DELETE, "cow and the "),
                new Diff(Operation.EQUAL, "cat.")}, diffs);
        }
开发者ID:victorarias,项目名称:dojo-centro,代码行数:67,代码来源:DiffMatchPatchTest.cs


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