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_byte_test() { IByteBuf buf = new AbstructByteBuf(256); buf.SetOffset(1); buf.WriteByte((byte)1); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 1); Assert.AreEqual(buf.WriteIndex, 2); Assert.AreEqual(buf.Readables(), 1); Assert.AreEqual(buf.Writeables(), 254); byte b1 = buf.ReadByte(); Assert.AreEqual(b1, 1); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 2); Assert.AreEqual(buf.WriteIndex, 2); Assert.AreEqual(buf.Readables(), 0); Assert.AreEqual(buf.Writeables(), 254); }
public void bytebuf_base_clear_test() { IByteBuf buf = new AbstructByteBuf(4); buf.SetOffset(1); buf.WriteByte((byte)1).ReadByte(); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 2); Assert.AreEqual(buf.WriteIndex, 2); Assert.AreEqual(buf.Readables(), 0); Assert.AreEqual(buf.Writeables(), 2); Assert.AreEqual(buf.Capacity, 3); buf.Clear(); Assert.AreEqual(buf.Offset, 1); Assert.AreEqual(buf.ReadIndex, 1); Assert.AreEqual(buf.WriteIndex, 1); Assert.AreEqual(buf.Readables(), 0); Assert.AreEqual(buf.Writeables(), 3); Assert.AreEqual(buf.Capacity, 3); Assert.AreNotEqual(buf.GetBytes(), AbstructByteBuf.Emtpy); }