public void BaseStream_IsBitStream()
 {
     var data = new byte[] {0x23, 0x72, 0x64, 0xe3, 0x11, 0xd1, 0x4a, 0x9c, 0xb6, 0x02};
     var stream = new MemoryStream(data);
     BitStream bitStream = new BitStreamReader(stream);
     var reader = new BitBinaryReader(bitStream);
     Assert.AreEqual(bitStream, reader.BaseStream);
 }
        public void VerifyEncoding_astrachan_()
        {
            string input = "astrachan_";
            var data = new MemoryStream();
            var writer = new BitBinaryWriter(data);
            var reader = new BitBinaryReader(data);

            var compressor = new DynamicHuffman<char>();

            for (int i = 0; i < input.Length; ++i)
            {
                compressor.WriteCode(input[i], writer.Write, writer.Write);
            }
            writer.Flush();
            data.Position = 0;

            var decompressor = new DynamicHuffman<char>();
            for (int i = 0; i < input.Length; ++i)
            {
                Assert.AreEqual(input[i], decompressor.GetSymbol(reader.ReadBoolean, reader.ReadChar));
            }
            Assert.AreEqual(data.Position, data.Length);
        }
        public void VerifyEncoding_largecorpus()
        {
            string input = TestResources.RFC5_Text;
            int len = input.Length;
            var data = new MemoryStream();
            var writer = new BitBinaryWriter(data);
            var reader = new BitBinaryReader(data);

            var compressor = new DynamicHuffman<char>();

            for (int i = 0; i < len; ++i)
            {
                compressor.WriteCode(input[i], writer.Write, writer.Write);
            }
            writer.Flush();
            data.Position = 0;

            var decompressor = new DynamicHuffman<char>();
            for (int i = 0; i < len; ++i)
            {
                Assert.AreEqual(input[i], decompressor.GetSymbol(reader.ReadBoolean, reader.ReadChar));
            }
            Assert.AreEqual(data.Position, data.Length);
        }
        public void BitBinaryWriterCompatible()
        {
            var stream = new MemoryStream();
            var writer = new BitBinaryWriter(stream);
            var reader = new BitBinaryReader(stream);

            foreach (TestValue value in _testValuesWithBits)
            {
                value.Write(writer);
            }

            writer.Flush();
            stream.Position = 0;

            foreach (TestValue value in _testValuesWithBits)
            {
                value.Read(reader);
            }
        }