• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2015 Google Inc. All Rights Reserved.
2 
3    Distributed under MIT license.
4    See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
5 */
6 
7 package org.brotli.dec;
8 
9 import static org.junit.Assert.assertEquals;
10 
11 import java.nio.ByteBuffer;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.junit.runners.JUnit4;
15 
16 /**
17  * Tests for {@link Dictionary}.
18  */
19 @RunWith(JUnit4.class)
20 public class DictionaryTest {
21 
crc64(ByteBuffer data)22   private static long crc64(ByteBuffer data) {
23     long crc = -1;
24     for (int i = 0; i < data.capacity(); ++i) {
25       long c = (crc ^ (long) (data.get(i) & 0xFF)) & 0xFF;
26       for (int k = 0; k < 8; k++) {
27         c = (c >>> 1) ^ (-(c & 1L) & -3932672073523589310L);
28       }
29       crc = c ^ (crc >>> 8);
30     }
31     return ~crc;
32   }
33 
34   @Test
testGetData()35   public void testGetData() {
36     assertEquals(37084801881332636L, crc64(Dictionary.getData()));
37   }
38 }
39