Esempio n. 1
0
        public void GetBytesTest()
        {
            AddCopyCollection ac = BinaryDiffTests.Diff("A", "BC");

            BinaryDiffTests.Check(ac, true);
            Addition add = (Addition)ac[0];

            Encoding.UTF8.GetString(add.GetBytes()).ShouldBe("BC");
        }
Esempio n. 2
0
        public void GDiffTest()
        {
            AddCopyCollection ac = BinaryDiffTests.Diff("Creative", "Creating", footprintLength: 2);

            BinaryDiffTests.Check(ac, false, true);
            using MemoryStream memory = new();
            ac.GDiff(memory);
            byte[] gdiff = memory.ToArray();
            gdiff.Length.ShouldBe(13);

            // It always starts with "d1ff d1ff 4" (magic numbers and version).
            Check(gdiff, 0, 0xd1, 0xff, 0xd1, 0xff, 0x04);

            // Copy (code 249) 6 bytes ("Creati").
            Check(gdiff, 5, 249, 0, 0, 6);

            // Add 2 bytes ("ng") and then EOF.
            Check(gdiff, 9, 2, (int)'n', (int)'g', 0);
        }
Esempio n. 3
0
        public void BinaryDiffLinesTest()
        {
            string            baseText = "The first one";
            AddCopyCollection ac       = BinaryDiffTests.Diff(baseText, "The second one", footprintLength: 4);

            BinaryDiffTests.Check(ac, false, true, false);

            using MemoryStream baseStream = new(Encoding.UTF8.GetBytes(baseText));
            BinaryDiffLines lines = new(baseStream, ac, 4);

            Check(lines.BaseLines,
                  "00000000    54 68 65 20    The ",
                  "00000004    66 69 72 73    firs",
                  "00000008    74             t",
                  "00000009    20 6F 6E 65     one");
            Check(lines.VersionLines,
                  "00000000    54 68 65 20    The ",
                  "00000004    73 65 63 6F    seco",
                  "00000008    6E 64          nd",
                  "0000000A    20 6F 6E 65     one");
        }