當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。