/// <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)); }
/// <exception cref="NGit.Errors.MissingObjectException"></exception> /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception> /// <exception cref="System.IO.IOException"></exception> /// <exception cref="NGit.Errors.LargeObjectException"></exception> private DeltaIndex Index(DeltaWindowEntry ent) { DeltaIndex idx = ent.index; if (idx == null) { try { idx = new DeltaIndex(Buffer(ent)); } catch (OutOfMemoryException noMemory) { LargeObjectException.OutOfMemory e; e = new LargeObjectException.OutOfMemory(noMemory); e.SetObjectId(ent.@object); throw e; } if (0 < maxMemory) { loaded += idx.GetIndexSize() - idx.GetSourceSize(); } ent.index = idx; } return idx; }
public virtual void TestLimitObjectSize_InsertFrontFails() { src = GetRng().NextBytes(130); Insert("eight"); Copy(0, 130); dst = dstBuf.ToByteArray(); // The header requires 4 bytes for these objects, so a target length // of 5 is bigger than the copy instruction and should cause an abort. // DeltaIndex di = new DeltaIndex(src); NUnit.Framework.Assert.IsFalse(di.Encode(actDeltaBuf, dst, 5)); NUnit.Framework.Assert.AreEqual(4, actDeltaBuf.Size()); }
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)); }
public virtual void TestLimitObjectSize_Length130InsertFails() { src = GetRng().NextBytes(130); dst = GetRng().NextBytes(130); DeltaIndex di = new DeltaIndex(src); NUnit.Framework.Assert.IsFalse(di.Encode(actDeltaBuf, dst, src.Length)); }
public virtual void TestIndexSize() { src = GetRng().NextBytes(1024); DeltaIndex di = new DeltaIndex(src); NUnit.Framework.Assert.AreEqual(1860, di.GetIndexSize()); NUnit.Framework.Assert.AreEqual("DeltaIndex[2 KiB]", di.ToString()); }
internal virtual void Set(ObjectToPack @object) { this.@object = @object; this.index = null; this.buffer = null; }