Skip to content
Permalink
Browse files
Whitespeace.
  • Loading branch information
garydgregory committed May 5, 2022
1 parent b9effe0 commit f1f99401612c3a4bc7a180fad7f91e828251d736
Showing 1 changed file with 0 additions and 34 deletions.
@@ -35,102 +35,68 @@
**/
public class ChecksumCalculatingInputStreamTest {



@Test
public void testSkipReturningZero() throws IOException {

final Adler32 adler32 = new Adler32();
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY);
final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
final long skipResult = checksumCalculatingInputStream.skip(60L);

assertEquals(0L, skipResult);

assertEquals(1L, checksumCalculatingInputStream.getValue());


}


@Test
public void testSkipReturningPositive() throws IOException {

final Adler32 adler32 = new Adler32();
final byte[] byteArray = new byte[6];
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
final long skipResult = checksumCalculatingInputStream.skip((byte)0);

assertEquals(1L, skipResult);

assertEquals(65537L, checksumCalculatingInputStream.getValue());

}


@Test
public void testReadTakingNoArguments() throws IOException {

final Adler32 adler32 = new Adler32();
final byte[] byteArray = new byte[6];
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
final BufferedInputStream bufferedInputStream = new BufferedInputStream(checksumCalculatingInputStream);
final int inputStreamReadResult = bufferedInputStream.read(byteArray, 0, 1);
final int checkSumCalculationReadResult = checksumCalculatingInputStream.read();

assertNotEquals(checkSumCalculationReadResult, inputStreamReadResult);
assertEquals((-1), checkSumCalculationReadResult);

assertEquals(0, byteArrayInputStream.available());

assertEquals(393217L, checksumCalculatingInputStream.getValue());

}


@Test
public void testReadTakingByteArray() throws IOException {

final Adler32 adler32 = new Adler32();
final byte[] byteArray = new byte[6];
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(adler32, byteArrayInputStream);
final int readResult = checksumCalculatingInputStream.read(byteArray);

assertEquals(6, readResult);

assertEquals(0, byteArrayInputStream.available());
assertEquals(393217L, checksumCalculatingInputStream.getValue());

}


@Test
public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionOne() {

final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,null);


}


@Test
public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionTwo() {

final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,new ByteArrayInputStream(new byte[1]));


}


@Test
public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionThree() {

final ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(new CRC32(),null);

}


}

0 comments on commit f1f9940

Please sign in to comment.