sclass Test_HuffmanByteArray { gettable HuffmanByteArray array; gettable HuffmanByteArray restoredArray; gettable byte[] compressed; void test(int... dataInts) { byte[] data = convertIntArrayToByteArray(dataInts); print("============="); printWithIndent("DATA | ", spaceIfEmpty(hexDump(data))); array = new HuffmanByteArray(data); compressed = array.toByteArray(); printWithIndent("COMP | ", hexDump(compressed)); restoredArray = new HuffmanByteArray().fromByteArray(compressed); printWithIndent("REST | ", spaceIfEmpty(hexDump(restoredArray!))); assertByteArrayEquals(data, restoredArray!); //printWithIndent(" OK | ", spaceIfEmpty(hexDump(data))); } 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); } }