Exemplo n.º 1
0
        public void WriteOneLSB()
        {
            var          buff   = new byte[1];
            var          mem    = new MemoryStream(buff);
            BitWriterLSB writer = new BitWriterLSB(mem);

            writer.WriteBits(1, 1);
            writer.Flush();
            Assert.AreEqual(1, buff[0]);
        }
Exemplo n.º 2
0
        public void ReadWriteLSB()
        {
            byte[] buff = new byte[0x1ff * 9 / 8 + 2];
            var    mem  = new MemoryStream(buff);

            BitWriterLSB writer = new BitWriterLSB(mem);

            for (int i = 0; i <= 0x1ff; i++)
            {
                writer.WriteBits(i, 9);
            }
            writer.Flush();

            mem.Seek(0, SeekOrigin.Begin);
            BitReaderLSB reader = new BitReaderLSB(mem);

            for (int i = 0; i <= 0x1ff; i++)
            {
                var val = reader.GetBits(9);
                Assert.AreEqual(i, val);
            }
        }