@Test public void testByteRange() { byte[] data = new byte[256]; for (int i = 0; i < data.length; i++) data[i] = (byte) i; roundTrip(data); }
@Test public void testTwoByte() { roundTrip(new byte[] { 0, 1 }); }
@Test public void testThreeByte() { roundTrip(new byte[] { 0, 1, 2 }); }
@Test public void testEmpty() { roundTrip(new byte[0]); }
@Test public void testOneByte() { roundTrip(new byte[] { 0 }); }
@Test public void testZeroBytes() { roundTrip(new byte[1000]); }
@Test public void testFourBytes() { roundTrip(new byte[] { 0, 1, 2, 3 }); }
private static void roundTrip(byte[] data, RANS.ORDER order) { roundTrip(ByteBuffer.wrap(data), order); }
@Test public void testByteMin() { byte[] data = new byte[1000]; Arrays.fill(data, Byte.MIN_VALUE); roundTrip(data); }
@Test public void testUniBytes() { byte[] data = new byte[1000]; Arrays.fill(data, (byte) 1); roundTrip(data); }
@Test public void testByteMax() { byte[] data = new byte[1000]; Arrays.fill(data, Byte.MAX_VALUE); roundTrip(data); }
@Test public void testZeroOneStretches() { byte[] data = new byte[1000]; Arrays.fill(data, data.length / 2, data.length, (byte) 1); roundTrip(data); }
private static void roundTrip(ByteBuffer data) { for (RANS.ORDER order : RANS.ORDER.values()) { roundTrip(data, order); data.rewind(); } }
@Test public void testXLSize() { int size = 10 * 1000 * 1000 + 1; roundTrip(randomBytes_GD(size, 0.01)); }
@Test public void testSizeRange_small() { byte[] data = randomBytes_GD(1000, 0.01); ByteBuffer in = ByteBuffer.wrap(data); for (int size = 4; size < data.length; size++) { in.position(0); in.limit(size); roundTrip(in); } }
@Test public void testLargeSize() { int size = 100 * 1000 + 3; byte[] data = randomBytes_GD(size, 0.01); ByteBuffer in = ByteBuffer.wrap(data); for (int limit = size - 4; limit < size; limit++) { in.position(0); in.limit(limit); roundTrip(in); } }
private static void roundTrip(byte[] data) { for (RANS.ORDER order : RANS.ORDER.values()) roundTrip(data, order); }
@Test public void test1000_0dot1() { roundTrip(randomBytes_GD(1000, 0.1)); }
@Test public void test1000_0dot01() { roundTrip(randomBytes_GD(1000, 0.01)); }
@Test public void testSizeRange_tiny() { for (int i = 0; i < 20; i++) { byte[] data = randomBytes_GD(100, 0.1); ByteBuffer in = ByteBuffer.wrap(data); for (int size = 1; size < data.length; size++) { in.position(0); in.limit(size); try { roundTrip(in); } catch (AssertionError e) { System.err.printf("Failed at size %d and data %s\n", size, Arrays.toString(data)); throw e; } } } }