sclass Test_HuffmanByteArray { gettable HuffmanByteArray array; gettable HuffmanByteArray restoredArray; gettable byte[] compressed; void test(int... dataInts) { byte[] data = convertIntArrayToByteArray(dataInts); array = new HuffmanByteArray(data); compressed = array.toByteArray(); restoredArray = new HuffmanByteArray().fromByteArray(compressed); printWithIndent("DATA", hexDump(data)); printWithIndent("COMP", hexDump(compressed)); printWithIndent("REST", hexDump(restoredArray!)); assertByteArrayEquals(data, restoredArray!); } run { test(); // empty array // try every single byte for (int i = 0; i < 256; i++) test((byte) i); // try some longer patterns test(0, 0); test(0, 1); test(0, 1, 2); test(3, 3, 4, 5); } }