Ejemplo n.º 1
0
        private void u32ReadWrite <TEncoder, TDecoder>()
            where TEncoder : struct, ICompression <RawBitWriter <u32ArrayMemory> >
            where TDecoder : struct, IDecompression <BitBufferReader <TDecoder> >
        {
            var writer = new BitBufferWriter <TEncoder>();

            writer.u32(u32.MinValue);
            writer.u32(u32.MaxValue);
            var data   = writer.ToArray();
            var reader = new BitBufferReader <TDecoder>();

            reader.CopyFrom(data);
            Assert.AreEqual(u32.MinValue, reader.u32());
            Assert.AreEqual(u32.MaxValue, reader.u32());
        }
Ejemplo n.º 2
0
        public void u32ReadWriteLimits <TEncoder, TDecoder>()
            where TEncoder : struct, ICompression <RawBitWriter <u32ArrayMemory> >
            where TDecoder : struct, IDecompression <RawBitReader <u32ArrayMemory> >
        {
            var writer = new BitBufferWriter <TEncoder>();

            writer.u32(123123, 0, 13213123);
            writer.u32(123, 20);
            var data   = writer.ToArray();
            var reader = new BitBufferReader <TDecoder>();

            reader.CopyFrom(data);
            Assert.AreEqual(123123u, reader.u32(0, 13213123));
            Assert.AreEqual(123u, reader.u32(20));
        }
        public void RawToEncodedReadWrite()
        {
            var rawWriter = new BitBufferWriter <RawEncoding <u32ArrayMemory> >();

            rawWriter.i32(i32.MaxValue - 13);
            rawWriter.u32(u32.MaxValue - 666);
            var rawReader = new BitBufferReader <RawDecoding <u32ArrayMemory> >();
            var data      = rawWriter.ToArray();

            rawReader.CopyFrom(data);
            Assert.AreEqual(i32.MaxValue - 13, rawReader.i32());
            Assert.AreEqual(u32.MaxValue - 666, rawReader.u32());
        }
Ejemplo n.º 4
0
        public i32 i32(BitBufferReader <FibonacciDecoding> b, u8 numberOfBits)
        {
            u32 value = b.u32(numberOfBits);

            return(decode(value));
        }