public void TestPosition() { var rnd = new Random(); for (var c = 0; c < count; c++) { var memSize = 10_000; var mem = new byte[memSize * 10]; var answer = new byte[memSize]; for (var i = 0; i < memSize; i++) { answer[i] = (byte)rnd.Next(0, 10); } var span1 = new SpanStream(mem); var span2 = new SpanStream(mem); for (var i = 0; i < memSize; i++) { span1.Position += answer[i]; span1.Write(answer[i]); } // Ensure span is not zero for (var i = 0; i < memSize; i++) { span2.Position += answer[i]; var r = span2.ReadByte(); Assert.Equal(answer[i], r); } } }
public void TestByte() { var rnd = new System.Random(); for (var c = 0; c < count; c++) { var mem = new byte[sizeof(Byte) * writeRepeatCount]; var span1 = new SpanStream(mem); var span2 = new SpanStream(mem); var a = new Byte[writeRepeatCount]; for (var i = 0; i < writeRepeatCount; i++) { var n = rnd.NextByte(); a[i] = n; span1.Write(n); } for (var i = 0; i < writeRepeatCount; i++) { var r = span2.ReadByte(); Assert.Equal(a[i], r); } } }