Beispiel #1
0
 public void testBitIOValues() {
   BitIOWriter writer = new BitIOWriter();
   writer.writeValue(0x55, 7);
   writer.writeValue(0x245, 10);
   writer.flush();
   byte[] result = writer.toByteArray();
   byte[] expected = {(byte) 0xab, (byte) 0x22, (byte) 0x80};
   assertEqualsByteArray(expected, result);
 }
Beispiel #2
0
 private void write(byte[] dataIn) {
   bits.writeBit(usingRunLength);
   length1 = dataIn.length;
   // If we want to do runlengths, here's the place, but I'm not convinced it's useful
   setDistRange(length1);
   distEncoder = new HuffmanEncoder(bits, 1 << DIST_WIDTH);
   lenEncoder = new HuffmanEncoder(bits, 1 << LEN_WIDTH);
   symEncoder = new HuffmanEncoder(bits, numSyms);
   buf = new byte[PRELOAD_SIZE + length1];
   System.arraycopy(dataIn, 0, buf, PRELOAD_SIZE, length1);
   encode();
   bits.flush();
 }
Beispiel #3
0
 public void testBitIOBool() {
   BitIOWriter writer = new BitIOWriter();
   writer.writeBit(true);
   writer.writeBit(false);
   writer.writeBit(true);
   writer.writeBit(true);
   writer.writeBit(false);
   writer.writeBit(false);
   writer.writeBit(true);
   writer.writeBit(false);
   writer.writeBit(true);
   writer.flush();
   byte[] result = writer.toByteArray();
   byte[] expected = {(byte) 0xb2, (byte) 0x80};
   assertEqualsByteArray(expected, result);
 }