private static void roundTrip(HuffmanEncoder encoder, HuffmanDecoder decoder, byte[] buf) { using(var baos = new MemoryStream()) { using(var dos = new BinaryWriter(baos)) { encoder.Encode(dos, buf); var actualBytes = decoder.Decode(baos.ToArray()); Assert.IsTrue(buf.SequenceEqual(actualBytes)); } } }
private static void roundTrip(HuffmanEncoder encoder, HuffmanDecoder decoder, string s) { roundTrip(encoder, decoder, Encoding.UTF8.GetBytes(s)); }