public void test_inflate$B() {
// test method of java.util.zip.inflater.inflate(byte)
byte byteArray[] = { 1, 3, 4, 7, 8, 'e', 'r', 't', 'y', '5' };
byte outPutInf[] = new byte[500];
Inflater inflate = new Inflater();
try {
while (!(inflate.finished())) {
if (inflate.needsInput()) {
inflate.setInput(outPutBuff1);
}
inflate.inflate(outPutInf);
}
} catch (DataFormatException e) {
fail("Invalid input to be decompressed");
}
for (int i = 0; i < byteArray.length; i++) {
assertTrue(
"Final decompressed data does not equal the original data",
byteArray[i] == outPutInf[i]);
}
assertEquals("final decompressed data contained more bytes than original - inflateB",
0, outPutInf[byteArray.length]);
// testing for an empty input array
byte outPutBuf[] = new byte[500];
byte emptyArray[] = new byte[11];
int x = 0;
Deflater defEmpty = new Deflater(3);
defEmpty.setInput(emptyArray);
while (!(defEmpty.needsInput())) {
x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
}
defEmpty.finish();
while (!(defEmpty.finished())) {
x += defEmpty.deflate(outPutBuf, x, outPutBuf.length - x);
}
assertTrue(
"the total number of byte from deflate did not equal getTotalOut - inflate(byte)",
x == defEmpty.getTotalOut());
assertTrue(
"the number of input byte from the array did not correspond with getTotalIn - inflate(byte)",
defEmpty.getTotalIn() == emptyArray.length);
Inflater infEmpty = new Inflater();
try {
while (!(infEmpty.finished())) {
if (infEmpty.needsInput()) {
infEmpty.setInput(outPutBuf);
}
infEmpty.inflate(outPutInf);
}
} catch (DataFormatException e) {
fail("Invalid input to be decompressed");
}
for (int i = 0; i < emptyArray.length; i++) {