Exemplo n.º 1
0
        public void i16ReadWrite()
        {
            var writer = new BitBufferWriter <SevenBitEncoding <u32ArrayMemory> >();

            writer.i16(i16.MinValue);
            writer.i16(i16.MinValue / 2);
            writer.i16(0);
            i16 half = i16.MaxValue / 2;

            writer.i16(half);
            writer.i16(i16.MaxValue);
            writer.Align();
            var allocated = new byte[i16.MaxValue];

            writer.ToSpan(allocated);
            var reader = new BitBufferReader <SevenBitDecoding <u32ArrayMemory> >(allocated.Length);

            reader.CopyFrom(allocated);
            Assert.AreEqual(i16.MinValue, reader.i16());
            Assert.AreEqual(i16.MinValue / 2, reader.i16());
            Assert.AreEqual(0, reader.i16());
            Assert.AreEqual(half, reader.i16Peek());
            Assert.AreEqual(half, reader.i16());
            Assert.AreEqual(i16.MaxValue, reader.i16());
        }