public virtual void testSize() { //If you pass in a buffer, Length == Capacity. //If you pass in an int, Length == Bytes used. ByteArrayIOStream ios = new ByteArrayIOStream(20000); byte[] ba = new byte[1]; for (long i = 0; i < 12345; i++) { ios.WriteByte((byte)i); Assert.AreEqual(1 + i, ios.Length); } }
public virtual void testInRead() { ByteArrayIOStream ios = new ByteArrayIOStream(); for (int i = 0; i < 200000; i++) { ios.WriteByte((byte)i); } Stream @is = ios.getInputStream(); int n = 0; int j; while ((j = @is.ReadByte()) >= 0) { Assert.AreEqual(n % 256, j, "" + n); n++; } Assert.AreEqual(200000, n); }