public void TestAppend() { var data0 = RandomBytes(10000000, 0); var data1 = RandomBytes(10000000, 1); var stats = TestByteBufferStatistics.Empty; using (var bb = new TestByteBuffer(data0)) { bb.Append(data1, 0, 750000); stats += bb.LastStatistics; bb.Append(data1, 750000, 750000 + 1); stats += bb.LastStatistics; bb.Append(data1, 1500000 + 1, 500000); stats += bb.LastStatistics; bb.Append(data1, 2000000 + 1, 1000000 - 1); stats += bb.LastStatistics; bb.Append(data1, 3000000, 1001101); stats += bb.LastStatistics; } using (var bb = new TestByteBuffer(data0)) { bb.InitializeStream(); bb.Append(data1, 0, 750000); stats += bb.LastStatistics; bb.Append(data1, 750000, 750000 + 1); stats += bb.LastStatistics; bb.Append(data1, 1500000 + 1, 500000); stats += bb.LastStatistics; bb.Append(data1, 2000000 + 1, 1000000 - 1); stats += bb.LastStatistics; bb.Append(data1, 3000000, 1001101); stats += bb.LastStatistics; } Console.WriteLine(stats); }
public void TestAppend() { var data0 = RandomBytes(8472, -0x02F0B4EF); var data1 = RandomBytes(8472, -0x7BFC1702); using (var bb = new TestByteBuffer(data0)) { bb.Append(data1, 4195, 4194); Assert.AreEqual(8472 + 4194, bb.Length, "Append - length"); Assert.AreEqual(0, bb.StreamPosition, "Append - StreamPosition"); AssertAreEqual(data0, 0, bb.DumpTestData(), 0, 8472, "Append - original data"); AssertAreEqual(data1, 4195, bb.DumpTestData(), 8472, 4194, "Append - appended data"); } using (var bb = new TestByteBuffer(data0)) { bb.InitializeStream(position: 42); bb.Append(data1, 4195, 4194); Assert.AreEqual(8472 + 4194, bb.Length, "Append - length - after Stream initialized"); Assert.AreEqual(42, bb.StreamPosition, "Append - StreamPosition - after Stream initialized"); AssertAreEqual(data0, 0, bb.DumpTestData(), 0, 8472, "Append - original data - after Stream initialized"); AssertAreEqual(data1, 4195, bb.DumpTestData(), 8472, 4194, "Append - appended data - after Stream initialized"); } }