Esempio n. 1
0
        public void TestGetDiff555()
        {
            // Arrange
            var merge = new Merge();


            var resDiff = new string[]
            {
                "1",
                "<<<<<<< A",
                "2",
                "||||||| O",
                "2",
                "3",
                "=======",
                ">>>>>>> B",
                "4",
                "6",
                "<<<<<<< A",
                "||||||| O",
                "7",
                "=======",
                "2",
                "3",
                "4",
                ">>>>>>> B",
                "8",
            };

            // Act

            var strsMatrOB = merge.LCSLength(O555, B555);
            var strsMatrOA = merge.LCSLength(O555, A555);
            var ob         = merge.BacktrackNormalize(merge.BacktrackEasy(strsMatrOB, O555, B555, O555.Length, B555.Length), O555, B555);
            var oa         = merge.BacktrackNormalize(merge.BacktrackEasy(strsMatrOA, O555, A555, O555.Length, A555.Length), O555, A555);

            var res = merge.MergeChunks(merge.DiffParse(oa, ob).ToList(), "A", "O", "B");


            // Assert
            if (res == null || res.Count() != resDiff.Count())
            {
                Assert.Fail("Result is null or empty");
            }
            for (int i = 0; i < resDiff.Count(); i++)
            {
                Assert.That(res.ElementAt(i), Is.EqualTo(resDiff[i]));
            }
        }
Esempio n. 2
0
        public void TestBacktrack()
        {
            // Arrange
            var merge = new Merge();

            // Act
            var OtoAcommonChunks = merge.BacktrackNormalize(merge.BacktrackEasy(_correctAOMatrix, O, A, O.Length, A.Length), O, A);

            // Assert

            Assert.That(OtoAcommonChunks, Is.EqualTo(_backtracksAO));
        }
Esempio n. 3
0
        public void TestDiffParse2()
        {
            // Arrange
            var merge = new Merge();

            // Act

            var strsMatrOB = merge.LCSLength(O, B);
            var ob         = merge.BacktrackNormalize(merge.BacktrackEasy(strsMatrOB, O, B, O.Length, B.Length), O, B);

            var res = merge.DiffParse(_backtracksAO, ob);

            // Assert
            if (res == null || res.Count() != _parsedRes.Count())
            {
                Assert.Fail("Result is null or empty");
            }
            for (int i = 0; i < res.Count(); i++)
            {
                Assert.That(res.ElementAt(i).ASeq.SequenceEqual(_parsedRes.ElementAt(i).Item1));
                Assert.That(res.ElementAt(i).OSeq.SequenceEqual(_parsedRes.ElementAt(i).Item2));
                Assert.That(res.ElementAt(i).BSeq.SequenceEqual(_parsedRes.ElementAt(i).Item3));
            }
        }
Esempio n. 4
0
        public void TestMerge_ConinsDifferendEnds()
        {
            // Arrange
            var merge = new Merge();


            var o = new string[]
            {
                "1",
                "2",
                "3",
            };

            var a = new string[]
            {
                "1",
                "2",
                "3",
                "10",
                "11",
                "12",
            };

            var b = new string[]
            {
                "1",
                "2",
                "3",
                "20",
                "21",
                "22",
                "23",
                "24",
                "25",
                "26",
            };

            var resDiff = new string[]
            {
                "1",
                "2",
                "3",
                "<<<<<<< A",
                "10",
                "11",
                "12",
                "||||||| O",
                "=======",
                "20",
                "21",
                "22",
                "23",
                "24",
                "25",
                "26",
                ">>>>>>> B"
            };

            // Act

            var strsMatrOB = merge.LCSLength(o, b);
            var strsMatrOA = merge.LCSLength(o, a);
            var ob         = merge.BacktrackNormalize(merge.BacktrackEasy(strsMatrOB, o, b, o.Length, b.Length), o, b);
            var oa         = merge.BacktrackNormalize(merge.BacktrackEasy(strsMatrOA, o, a, o.Length, a.Length), o, a);

            var res = merge.MergeChunks(merge.DiffParse(oa, ob).ToList(), "A", "O", "B");


            // Assert
            if (res == null || res.Count() != resDiff.Count())
            {
                Assert.Fail("Result is null or empty or row count is wrong");
            }
            for (int i = 0; i < resDiff.Count(); i++)
            {
                Assert.That(res.ElementAt(i), Is.EqualTo(resDiff[i]));
            }
        }