package com.webcodepro.shrinkit.io; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * Exercise the LZW encoder and decoders. * * @author robgreene@users.sourceforge.net */ public class LzwTest extends TestCaseHelper { public void testLzwDecoder() throws IOException { LzwInputStream is = new LzwInputStream(new BitInputStream(new ByteArrayInputStream(getHgrColorsLzw1()), 9)); int[] expected = getHgrColorsUncompressed(); int[] actual = new int[expected.length]; for (int i=0; i 0) System.out.println(); System.out.printf("%08x: ", bytes); } System.out.printf("%02x ", b); bytes++; } } public void testLzwDecoder3() throws IOException { LzwInputStream is = new LzwInputStream(new BitInputStream(new ByteArrayInputStream(getTextFileLzw1()), 9)); System.out.printf("\n\nText File decoded...\n\n"); int i = 0; int b = 0; while (b != -1) { b = is.read(); if (b != -1) System.out.printf("$%04x: %02x (%c)\n", i++, b, b); } System.out.printf("** END **"); } protected byte[] asBytes(int[] source) { byte[] array = new byte[source.length]; for (int i=0; i