public void bytebuf_base_init_setbytes_test() { IByteBuf buf = new AbstructByteBuf(); byte[] arr = new byte[256]; buf.SetBytes(arr); Assert.AreEqual(buf.Offset, 0); Assert.AreEqual(buf.ReadIndex, 0); Assert.AreEqual(buf.WriteIndex, 0); Assert.AreEqual(buf.Readables(), 0); Assert.AreEqual(buf.Writeables(), 256); buf.Clear(); }
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); }