public void TestSize() { var rnd = new System.Random(); for (var c = 0; c < count; c++) { var mem = new byte[sizeof(UInt32) * writeRepeatCount]; var span1 = new SpanStream(mem); var span2 = new SpanStream(mem); var a = new UInt32[writeRepeatCount]; for (var i = 0; i < writeRepeatCount; i++) { var sr = rnd.Next(0, 4); uint n; switch (sr) { case 0: n = (UInt32)rnd.Next(0, 0b00111111); break; case 1: n = (UInt32)rnd.Next(0b01000000, 0b00111111_11111111); break; case 2: n = (UInt32)rnd.Next(0b01000000_00000000, 0b00111111_11111111_11111111); break; //case 3: default: n = (UInt32)rnd.Next(0b01000000_00000000_00000000, 0b00111111_11111111_11111111_11111111); break; } a[i] = n; span1.WriteSize(n); } for (var i = 0; i < writeRepeatCount; i++) { var r = span2.ReadSize(out var len); Assert.Equal(span2.MeasureWriteSize(a[i]), len); Assert.Equal(a[i], r); } } }