public void TestDiff01()
        {
            Dictionary <string, string> files = TestUtils.ExtractZippedFiles("Files01");

            (int added, int deleted) = DiffGenerator.GetLinesChanged(files["JsonSerializerTest_4793c7b.cs"], files["JsonSerializerTest_2368a8e.cs"]);
            Assert.AreEqual(23, added);
            Assert.AreEqual(0, deleted);
        }
        public void TestOverlap()
        {
            string text1 = @"
                az
                az
                ab
                ac";
            string text2 = @"
                az
                ab
                ac";

            (int added, int deleted) = DiffGenerator.GetLinesChanged(text1, text2);
            Assert.AreEqual(0, added);
            Assert.AreEqual(1, deleted);
        }
Beispiel #3
0
        public void PerformanceTest()
        {
            int comparisons = 600;

            Prepare(comparisons, out string[] content1, out string[] content2);
            int    repeatCount = 25;
            double total       = 0;

            foreach (int repeat in Enumerable.Range(0, repeatCount))
            {
                TestContext.Progress.Write(repeat);
                Stopwatch watch = Stopwatch.StartNew();
                for (int i = 0; i < comparisons; i++)
                {
                    DiffGenerator.GetLinesChanged(content1[0], content2[0]);
                }
                watch.Stop();
                total += watch.ElapsedMilliseconds;
            }
            Console.WriteLine($"Average {total / repeatCount}ms");
            TestContext.Progress.WriteLine($"Average {total / repeatCount}ms");
        }