public void bytebuf_write_array_test() { IByteBuf buf = new AbstructByteBuf(256); byte[] arr = { 0, 1, 2, 3, 4 }; buf.SetOffset(1); buf.Write(arr); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 1); Assert.AreEqual(buf.WriteIndex, 6); Assert.AreEqual(buf.Readables(), 5); Assert.AreEqual(buf.Writeables(), 250); }
public void bytebuf_write_bytebuf_offset_test() { var buf1 = new AbstructByteBuf(256); var buf2 = new AbstructByteBuf(9); for (byte i = 0; i < 9; i++) { buf2.WriteByte(i); } buf1.SetOffset(1); buf1.Write(buf2, 7); Assert.AreEqual(buf1.Offset, 1); Assert.AreEqual(buf1.ReadIndex, 1); Assert.AreEqual(buf1.WriteIndex, 8); Assert.AreEqual(buf1.Readables(), 7); Assert.AreEqual(buf1.Writeables(), 248); }
public void bytebuf_writeread_int_test() { IByteBuf buf = new AbstructByteBuf(256); buf.SetOffset(1); buf.Write(1); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 1); Assert.AreEqual(buf.WriteIndex, 5); Assert.AreEqual(buf.Readables(), 4); Assert.AreEqual(buf.Writeables(), 251); int b = buf.ReadInt32(); Assert.AreEqual(b, 1); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 5); Assert.AreEqual(buf.WriteIndex, 5); Assert.AreEqual(buf.Readables(), 0); Assert.AreEqual(buf.Writeables(), 251); }