Example #1
0
        public void TestGetUnsigned()
        {
            IoBuffer buf = IoBuffer.Allocate(16);

            buf.Put((byte)0xA4);
            buf.Put((byte)0xD0);
            buf.Put((byte)0xB3);
            buf.Put((byte)0xCD);
            buf.Flip();

            buf.Order = ByteOrder.LittleEndian;

            buf.Mark();
            Assert.AreEqual(0xA4, buf.Get());
            buf.Reset();
            Assert.AreEqual(0xD0A4, (UInt16)buf.GetInt16());
            buf.Reset();
            Assert.AreEqual(0xCDB3D0A4L, (UInt32)buf.GetInt32());
        }
Example #2
0
        public void TestAutoExpandMark()
        {
            IoBuffer buf = ByteBufferAllocator.Instance.Allocate(4);

            buf.AutoExpand = true;

            buf.Put((byte)0);
            buf.Put((byte)0);
            buf.Put((byte)0);

            // Position should be 3 when we reset this buffer.
            buf.Mark();

            // Overflow it
            buf.Put((byte)0);
            buf.Put((byte)0);

            Assert.AreEqual(5, buf.Position);
            buf.Reset();
            Assert.AreEqual(3, buf.Position);
        }