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 BinaryReaderCompatible_WithoutBits() { var stream = new MemoryStream(); var writer = new BitBinaryWriter(stream); var reader = new BinaryReader(stream); foreach (TestValue value in _testValues) { value.Write(writer); } writer.Flush(); stream.Position = 0; foreach (TestValue value in _testValues) { value.Read(reader); } }