當前位置: 首頁>>代碼示例>>C#>>正文


C# diff_match_patchTest.diff_path2方法代碼示例

本文整理匯總了C#中nicTest.diff_match_patchTest.diff_path2方法的典型用法代碼示例。如果您正苦於以下問題:C# diff_match_patchTest.diff_path2方法的具體用法?C# diff_match_patchTest.diff_path2怎麽用?C# diff_match_patchTest.diff_path2使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在nicTest.diff_match_patchTest的用法示例。


在下文中一共展示了diff_match_patchTest.diff_path2方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: diff_pathTest

        public void diff_pathTest()
        {
            diff_match_patchTest dmp = new diff_match_patchTest();
            // First, check footprints are different.
            Assert.IsTrue(dmp.diff_footprint(1, 10) != dmp.diff_footprint(10, 1), "diff_footprint:");

            // Single letters.
            // Trace a path from back to front.
            List<HashSet<long>> v_map;
            HashSet<long> row_set;
            v_map = new List<HashSet<long>>();
            {
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 0));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 1));
                row_set.Add(dmp.diff_footprint(1, 0));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 2));
                row_set.Add(dmp.diff_footprint(2, 0));
                row_set.Add(dmp.diff_footprint(2, 2));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 3));
                row_set.Add(dmp.diff_footprint(2, 3));
                row_set.Add(dmp.diff_footprint(3, 0));
                row_set.Add(dmp.diff_footprint(4, 3));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 4));
                row_set.Add(dmp.diff_footprint(2, 4));
                row_set.Add(dmp.diff_footprint(4, 0));
                row_set.Add(dmp.diff_footprint(4, 4));
                row_set.Add(dmp.diff_footprint(5, 3));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 5));
                row_set.Add(dmp.diff_footprint(2, 5));
                row_set.Add(dmp.diff_footprint(4, 5));
                row_set.Add(dmp.diff_footprint(5, 0));
                row_set.Add(dmp.diff_footprint(6, 3));
                row_set.Add(dmp.diff_footprint(6, 5));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 6));
                row_set.Add(dmp.diff_footprint(2, 6));
                row_set.Add(dmp.diff_footprint(4, 6));
                row_set.Add(dmp.diff_footprint(6, 6));
                row_set.Add(dmp.diff_footprint(7, 5));
                v_map.Add(row_set);
            }

            List<Diff> diffs = new List<Diff>{
                new Diff(Operation.INSERT, "W"),
                new Diff(Operation.DELETE, "A"),
                new Diff(Operation.EQUAL, "1"),
                new Diff(Operation.DELETE, "B"),
                new Diff(Operation.EQUAL, "2"),
                new Diff(Operation.INSERT, "X"),
                new Diff(Operation.DELETE, "C"),
                new Diff(Operation.EQUAL, "3"),
                new Diff(Operation.DELETE, "D")};
            CollectionAssert.AreEqual(diffs, dmp.diff_path1(v_map, "A1B2C3D", "W12X3"), "diff_path1: Single letters.");

            // Trace a path from front to back.
            v_map.RemoveAt(v_map.Count - 1);
            diffs = new List<Diff>{
                new Diff(Operation.EQUAL, "4"),
                new Diff(Operation.DELETE, "E"),
                new Diff(Operation.INSERT, "Y"),
                new Diff(Operation.EQUAL, "5"),
                new Diff(Operation.DELETE, "F"),
                new Diff(Operation.EQUAL, "6"),
                new Diff(Operation.DELETE, "G"),
                new Diff(Operation.INSERT, "Z")};
            CollectionAssert.AreEqual(diffs, dmp.diff_path2(v_map, "4E5F6G", "4Y56Z"), "diff_path2: Single letters.");

            // Double letters.
            // Trace a path from back to front.
            v_map = new List<HashSet<long>>();
            {
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 0));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 1));
                row_set.Add(dmp.diff_footprint(1, 0));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 2));
                row_set.Add(dmp.diff_footprint(1, 1));
                row_set.Add(dmp.diff_footprint(2, 0));
                v_map.Add(row_set);
                row_set = new HashSet<long>();
                row_set.Add(dmp.diff_footprint(0, 3));
                row_set.Add(dmp.diff_footprint(1, 2));
                row_set.Add(dmp.diff_footprint(2, 1));
                row_set.Add(dmp.diff_footprint(3, 0));
//.........這裏部分代碼省略.........
開發者ID:victorarias,項目名稱:dojo-centro,代碼行數:101,代碼來源:DiffMatchPatchTest.cs


注:本文中的nicTest.diff_match_patchTest.diff_path2方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。