Ejemplo n.º 1
0
            public void Will_return_correct_modifications_for_strings_with_one_difference()
            {
                var differ = new TestableDiffer();
                var a      = new ModificationData("matt\ncat\nhat\n");
                var b      = new ModificationData("matt\ncat\ntat\nhat\n");

                a.HashedPieces  = new[] { 1, 2, 3 };
                b.HashedPieces  = new[] { 1, 2, 4, 3 };
                a.Modifications = new bool[a.HashedPieces.Length];
                b.Modifications = new bool[b.HashedPieces.Length];

                differ.TestBuildModificationData(a, b);

                Assert.False(a.Modifications[0]);
                Assert.False(a.Modifications[1]);
                Assert.False(a.Modifications[2]);

                Assert.False(b.Modifications[0]);
                Assert.False(b.Modifications[1]);
                Assert.True(b.Modifications[2]);
                Assert.False(b.Modifications[3]);
            }
Ejemplo n.º 2
0
            public void Will_return_all_modifications_for_unique_strings()
            {
                var differ = new TestableDiffer();
                var a      = new ModificationData("cat\nhat\npat\nmatt");
                var b      = new ModificationData("door\nfloor\nbore\nmore");

                a.HashedPieces  = new[] { 1, 2, 3, 4 };
                b.HashedPieces  = new[] { 5, 6, 7, 8 };
                a.Modifications = new bool[a.HashedPieces.Length];
                b.Modifications = new bool[b.HashedPieces.Length];

                differ.TestBuildModificationData(a, b);

                foreach (var mod in a.Modifications)
                {
                    Assert.True(mod);
                }
                foreach (var mod in b.Modifications)
                {
                    Assert.True(mod);
                }
            }
Ejemplo n.º 3
0
            public void Will_return_correct_modifications_two_partially_similar_strings()
            {
                var differ = new TestableDiffer();
                var a      = new ModificationData("cat\nhat\npat\nmatt");
                var b      = new ModificationData("cat\nmatt\ntac");

                a.HashedPieces  = new[] { 1, 2, 3, 4 };
                b.HashedPieces  = new[] { 1, 4, 5 };
                a.Modifications = new bool[a.HashedPieces.Length];
                b.Modifications = new bool[b.HashedPieces.Length];

                differ.TestBuildModificationData(a, b);

                Assert.False(a.Modifications[0]);
                Assert.True(a.Modifications[1]);
                Assert.True(a.Modifications[2]);
                Assert.False(a.Modifications[3]);

                Assert.False(b.Modifications[0]);
                Assert.False(b.Modifications[1]);
                Assert.True(b.Modifications[2]);
            }
Ejemplo n.º 4
0
            public void Will_return_no_modifications_for_same_strings()
            {
                var differ = new TestableDiffer();
                var a      = new ModificationData("cat\nhat\npat\nmatt");
                var b      = new ModificationData("cat\nhat\npat\nmatt");

                a.HashedPieces  = new[] { 1, 2, 3, 4 };
                b.HashedPieces  = new[] { 1, 2, 3, 4 };
                a.Modifications = new bool[a.HashedPieces.Length];
                b.Modifications = new bool[b.HashedPieces.Length];

                differ.TestBuildModificationData(a, b);

                foreach (var mod in a.Modifications)
                {
                    Assert.False(mod);
                }
                foreach (var mod in b.Modifications)
                {
                    Assert.False(mod);
                }
            }