Formatting
This commit is contained in:
parent
955f7ab1eb
commit
84fb830481
|
@ -43,39 +43,39 @@ public class EnhancedDoubleHasherTest extends AbstractHasherTest {
|
|||
@Test
|
||||
public void testByteConstructor() {
|
||||
// single value become increment.
|
||||
EnhancedDoubleHasher hasher = new EnhancedDoubleHasher( new byte[] { 1 } );
|
||||
assertEquals( 0, hasher.getInitial() );
|
||||
assertEquals( 0x01_00_00_00_00_00_00_00L, hasher.getIncrement() );
|
||||
EnhancedDoubleHasher hasher = new EnhancedDoubleHasher(new byte[] {1});
|
||||
assertEquals(0, hasher.getInitial());
|
||||
assertEquals(0x01_00_00_00_00_00_00_00L, hasher.getIncrement());
|
||||
|
||||
// 2 bytes become initial and increment.
|
||||
hasher = new EnhancedDoubleHasher( new byte[] { 1, 2 } );
|
||||
assertEquals( 0x01_00_00_00_00_00_00_00L, hasher.getInitial() );
|
||||
assertEquals( 0x200000000000000L, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {1, 2});
|
||||
assertEquals(0x01_00_00_00_00_00_00_00L, hasher.getInitial());
|
||||
assertEquals(0x02_00_00_00_00_00_00_00L, hasher.getIncrement());
|
||||
|
||||
// odd values place extra byte in increment.
|
||||
hasher = new EnhancedDoubleHasher( new byte[] { 1, 2, 3 } );
|
||||
assertEquals( 0x01_00_00_00_00_00_00_00L, hasher.getInitial() );
|
||||
assertEquals( 0x203000000000000L, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {1, 2, 3});
|
||||
assertEquals(0x01_00_00_00_00_00_00_00L, hasher.getInitial());
|
||||
assertEquals(0x02_03_00_00_00_00_00_00L, hasher.getIncrement());
|
||||
|
||||
// even short split
|
||||
hasher = new EnhancedDoubleHasher( new byte[] {0, 1, 0, 2 } );
|
||||
assertEquals( 0x01_00_00_00_00_00_00L, hasher.getInitial() );
|
||||
assertEquals( 0x02_00_00_00_00_00_00L, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {0, 1, 0, 2});
|
||||
assertEquals(0x01_00_00_00_00_00_00L, hasher.getInitial());
|
||||
assertEquals(0x02_00_00_00_00_00_00L, hasher.getIncrement());
|
||||
|
||||
// longs are parse correctly
|
||||
hasher = new EnhancedDoubleHasher( new byte[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2 } );
|
||||
assertEquals( 1, hasher.getInitial() );
|
||||
assertEquals( 2, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2});
|
||||
assertEquals(1, hasher.getInitial());
|
||||
assertEquals(2, hasher.getIncrement());
|
||||
|
||||
// excess bytes are ignored before mid point and at end
|
||||
hasher = new EnhancedDoubleHasher( new byte[] { 0, 0, 0, 0, 0, 0, 0, 1, 5, 5, 0, 0, 0, 0, 0, 0, 0, 2, 5, 5 } );
|
||||
assertEquals( 1, hasher.getInitial() );
|
||||
assertEquals( 2, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {0, 0, 0, 0, 0, 0, 0, 1, 5, 5, 0, 0, 0, 0, 0, 0, 0, 2, 5, 5});
|
||||
assertEquals(1, hasher.getInitial());
|
||||
assertEquals(2, hasher.getIncrement());
|
||||
|
||||
// odd extra bytes are accounted for correctly
|
||||
hasher = new EnhancedDoubleHasher( new byte[] { 0, 0, 0, 0, 0, 0, 0, 1, 5, 1, 0, 0, 0, 0, 0, 0, 2, 5, 5 } );
|
||||
assertEquals( 1, hasher.getInitial() );
|
||||
assertEquals( 0x01_00_00_00_00_00_00_02L, hasher.getIncrement() );
|
||||
hasher = new EnhancedDoubleHasher(new byte[] {0, 0, 0, 0, 0, 0, 0, 1, 5, 1, 0, 0, 0, 0, 0, 0, 2, 5, 5});
|
||||
assertEquals(1, hasher.getInitial());
|
||||
assertEquals(0x01_00_00_00_00_00_00_02L, hasher.getIncrement());
|
||||
|
||||
// test empty buffer
|
||||
assertThrows(IllegalArgumentException.class, () -> new EnhancedDoubleHasher(new byte[0]));
|
||||
|
|
Loading…
Reference in New Issue