Sse42Crc32C extends AbstractIncrementalIntHash implements IncrementalIntHash { @Override public int calculate(long address, long length) { return nativeUnsafe(initial(), address, length, config); } Sse42Crc32C();   Sse42Crc32C(int chunkWords[]); static boolean isSupported(); @Override String algorithm(); @Override int length(); @Override boolean supportsUnsafe(); @Override int calculate(long address, long length); @Override int resume(int current, ByteBuffer input); @Override int resume(int current, long address, long length);  }
@Test public void testByteBuffer() { final ByteBuffer buf = ByteBuffer.allocate(1024); assertEquals(0xeeaede7c, NATIVE_CRC32C.calculate(buf)); }
@Test public void testDirectByteBuffer() { final ByteBuffer buf = ByteBuffer.allocateDirect(1024); assertEquals(0xeeaede7c, NATIVE_CRC32C.calculate(buf)); }
@Test public void testReadOnlyByteBuffer() { final ByteBuffer buf = ByteBuffer.allocate(1024).asReadOnlyBuffer(); assertEquals(0xeeaede7c, NATIVE_CRC32C.calculate(buf)); }
@Test public void testUnaligned() { final byte[] bytes = "123456789".getBytes(ASCII); assertEquals(0xbfe92a83, NATIVE_CRC32C.calculate(bytes, 1, 8)); }
@Test public void testChunking() { final int minWords = ChunkedCrcParameters.MIN_CHUNK_WORDS; final int maxWords = minWords * 2; final int len = maxWords * 8; final byte[] bytes = new byte[len]; final int expected = new StandardCrcProvider().getIncrementalInt(CRC32C).calculate(bytes); for (int i = minWords; i <= maxWords; ++i) { final ChunkedCrcParameters params = new ChunkedCrcParameters(CRC32C, new int[] { i }); final IncrementalIntHash impl = PROVIDER.getIncrementalInt(params); assertEquals(expected, impl.calculate(bytes)); } }