Exemplo n.º 1
0
        private bool GeneratePatchAndApply(byte[] a, byte[] b, int chunk_size)
        {
            ObjectPatch.ObjectPatch op = ObjectPatch.ObjectPatchRuntime.GeneratePatch(a, b, chunk_size);

            Assert.IsTrue(op.patchedLength == b.Length);

            byte[] result = ObjectPatch.ObjectPatchRuntime.ApplyPatch(a, op);
            return(ArraysAreEqual(b, result));
        }
Exemplo n.º 2
0
        private bool GeneratePatchAndApply(byte[] a, byte[] b)
        {
            int[] chunk_sizes = { 4, 8, 16, 32, 64, 128, 256, 512 };
            for (int i = 0; i < chunk_sizes.Length; ++i)
            {
                ObjectPatch.ObjectPatch op = ObjectPatch.ObjectPatchRuntime.GeneratePatch(a, b, chunk_sizes[i]);

                Assert.IsTrue(op.patchedLength == b.Length);

                byte[] result = ObjectPatch.ObjectPatchRuntime.ApplyPatch(a, op);
                if (!ArraysAreEqual(b, result))
                {
                    Console.WriteLine("Failed to correctly patch with chunk size {0}", chunk_sizes[i]);
                    return(false);
                }
            }
            return(true);
        }