当前位置: 首页>>代码示例>>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;未经允许,请勿转载。