Libraryless. Click here for Pure Java version (15640L/92K).
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); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035680 |
Snippet name: | Test_HuffmanByteArray |
Eternal ID of this version: | #1035680/11 |
Text MD5: | 50d1a5f882bb313b61d8e4bed7f24247 |
Transpilation MD5: | eab25088c27201c91d5e5856a8156b45 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-06 20:54:26 |
Source code size: | 994 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 194 / 339 |
Version history: | 10 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) |