Пример #1
0
        public virtual void TestLimitObjectSize_Length130CopyOk()
        {
            src = GetRng().NextBytes(130);
            Copy(0, 130);
            dst = dstBuf.ToByteArray();
            DeltaIndex di = new DeltaIndex(src);

            NUnit.Framework.Assert.IsTrue(di.Encode(actDeltaBuf, dst, dst.Length));
            byte[] actDelta = actDeltaBuf.ToByteArray();
            byte[] expDelta = expDeltaBuf.ToByteArray();
            NUnit.Framework.Assert.AreEqual(BinaryDelta.Format(expDelta, false), BinaryDelta.
                                            Format(actDelta, false));
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"></exception>
        private void DoTest()
        {
            dst = dstBuf.ToByteArray();
            DeltaIndex di = new DeltaIndex(src);

            di.Encode(actDeltaBuf, dst);
            byte[] actDelta = actDeltaBuf.ToByteArray();
            byte[] expDelta = expDeltaBuf.ToByteArray();
            NUnit.Framework.Assert.AreEqual(BinaryDelta.Format(expDelta, false), BinaryDelta.
                                            Format(actDelta, false));
            //
            NUnit.Framework.Assert.IsTrue(actDelta.Length > 0, "delta is not empty");
            NUnit.Framework.Assert.AreEqual(src.Length, BinaryDelta.GetBaseSize(actDelta));
            NUnit.Framework.Assert.AreEqual(dst.Length, BinaryDelta.GetResultSize(actDelta));
            CollectionAssert.AreEquivalent(dst, BinaryDelta.Apply(src, actDelta));
        }
Пример #3
0
        /// <exception cref="System.IO.IOException"></exception>
        private void AssertValidState()
        {
            NUnit.Framework.Assert.AreEqual(data.Length, dataPtr, "test filled example result"
                                            );
            delta = deltaBuf.ToByteArray();
            NUnit.Framework.Assert.AreEqual(@base.Length, BinaryDelta.GetBaseSize(delta));
            NUnit.Framework.Assert.AreEqual(data.Length, BinaryDelta.GetResultSize(delta));
            var appliedDelta = BinaryDelta.Apply(@base, delta);

            Assert.AreEqual(data.Length, appliedDelta.Length);
            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], appliedDelta[i]);
            }

            // Assert that a single bulk read produces the correct result.
            //
            byte[]      act = new byte[data.Length];
            DeltaStream @in = Open();

            NUnit.Framework.Assert.AreEqual(data.Length, @in.GetSize());
            NUnit.Framework.Assert.AreEqual(data.Length, @in.Read(act));
            NUnit.Framework.Assert.AreEqual(-1, @in.Read());
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(data, act), "bulk read has same content"
                                          );
            // Assert that smaller tiny reads have the same result too.
            //
            act = new byte[data.Length];
            @in = Open();
            int read = 0;

            while (read < data.Length)
            {
                int n = @in.Read(act, read, 128);
                if (n <= 0)
                {
                    break;
                }
                read += n;
            }
            NUnit.Framework.Assert.AreEqual(data.Length, read);
            NUnit.Framework.Assert.AreEqual(-1, @in.Read());
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(data, act), "small reads have same content"
                                          );
        }