diff options
author | Eugene Kliuchnikov <eustas@google.com> | 2017-04-10 15:39:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-10 15:39:00 +0200 |
commit | 66e798d46ae95af5fcd569b5b2ec71001688ced4 (patch) | |
tree | e2ff3dd83e0858ebdf6bbff3cb129c46a90e8464 /java/org/brotli/dec/DictionaryTest.java | |
parent | 46c1a881b41bb638c76247558aa04b1591af3aa7 (diff) | |
download | brotli-66e798d46ae95af5fcd569b5b2ec71001688ced4.zip brotli-66e798d46ae95af5fcd569b5b2ec71001688ced4.tar.gz brotli-66e798d46ae95af5fcd569b5b2ec71001688ced4.tar.bz2 |
Update API to v1.0.0 (#537)
Make Java decoder fully transpilable to C#.
Diffstat (limited to 'java/org/brotli/dec/DictionaryTest.java')
-rwxr-xr-x | java/org/brotli/dec/DictionaryTest.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/java/org/brotli/dec/DictionaryTest.java b/java/org/brotli/dec/DictionaryTest.java index eb0b46e..cf5c1cd 100755 --- a/java/org/brotli/dec/DictionaryTest.java +++ b/java/org/brotli/dec/DictionaryTest.java @@ -8,8 +8,6 @@ package org.brotli.dec; import static org.junit.Assert.assertEquals; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -20,12 +18,20 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class DictionaryTest { + private static long crc64(byte[] data) { + long crc = -1; + for (int i = 0; i < data.length; ++i) { + long c = (crc ^ (long) (data[i] & 0xFF)) & 0xFF; + for (int k = 0; k < 8; k++) { + c = (c >>> 1) ^ (-(c & 1L) & -3932672073523589310L); + } + crc = c ^ (crc >>> 8); + } + return ~crc; + } + @Test - public void testGetData() throws NoSuchAlgorithmException { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(Dictionary.getData()); - byte[] digest = md.digest(); - String sha256 = String.format("%064x", new java.math.BigInteger(1, digest)); - assertEquals("20e42eb1b511c21806d4d227d07e5dd06877d8ce7b3a817f378f313653f35c70", sha256); + public void testGetData() { + assertEquals(37084801881332636L, crc64(Dictionary.getData())); } } |