public void TestChop() { var data0 = RandomBytes(10000000, 0); var stats = TestByteBufferStatistics.Empty; using (var bb = new TestByteBuffer(data0)) { bb.Chop(1000000); stats += bb.LastStatistics; bb.Chop(1000000 - 1); stats += bb.LastStatistics; bb.Chop(1000000 + 1); stats += bb.LastStatistics; bb.Chop(1000000 - 2); stats += bb.LastStatistics; bb.Chop(1000000 + 2); stats += bb.LastStatistics; } using (var bb = new TestByteBuffer(data0)) { bb.InitializeStream(); bb.Chop(1000000); stats += bb.LastStatistics; bb.Chop(1000000 - 1); stats += bb.LastStatistics; bb.Chop(1000000 + 1); stats += bb.LastStatistics; bb.Chop(1000000 - 2); stats += bb.LastStatistics; bb.Chop(1000000 + 2); stats += bb.LastStatistics; } Console.WriteLine(stats); }
public void TestChop() { var data0 = RandomBytes(6000, -0x02F0B4EF); using (var bb = new TestByteBuffer(data0)) { bb.Chop(6000); Assert.AreEqual(0, bb.Length, "Chop(6000) - Length"); Assert.AreEqual(0, bb.StreamPosition, "Chop(6000) - StreamPosition"); AssertAreEqual(new byte[0], bb.DumpTestData(), "Chop(6000)"); } using (var bb = new TestByteBuffer(data0)) { bb.Chop(401); Assert.AreEqual(6000 - 401, bb.Length, "Chop(401) - Length"); Assert.AreEqual(0, bb.StreamPosition, "Chop(401) - StreamPosition"); AssertAreEqual(data0, 401, bb.DumpTestData(), 0, 5599, "Chop(401)"); } using (var bb = new TestByteBuffer(data0)) { bb.InitializeStream(position: 42); bb.Chop(6000); Assert.AreEqual(0, bb.Length, "Chop(6000) - Length - after Stream initialized"); Assert.AreEqual(0, bb.StreamPosition, "Chop(6000) - StreamPosition - after Stream initialized"); AssertAreEqual(new byte[0], bb.DumpTestData(), "Chop(6000) - after Stream initialized"); } using (var bb = new TestByteBuffer(data0)) { bb.InitializeStream(position: 42); bb.Chop(401); Assert.AreEqual(6000 - 401, bb.Length, "Chop(401) - Length - after Stream initialized"); Assert.AreEqual(0, bb.StreamPosition, "Chop(401) - StreamPosition - after Stream initialized"); AssertAreEqual(data0, 401, bb.DumpTestData(), 0, 5599, "Chop(401) - after Stream initialized"); } }