public static BetaIntegerEncoding fromParams(final byte[] data) { final ByteBuffer buffer = ByteBuffer.wrap(data); final int offset = ITF8.readUnsignedITF8(buffer); final int bitLimit = ITF8.readUnsignedITF8(buffer); return new BetaIntegerEncoding(offset, bitLimit); }
public static BetaIntegerEncoding fromParams(final byte[] data) { final ByteBuffer buffer = ByteBuffer.wrap(data); final int offset = ITF8.readUnsignedITF8(buffer); final int bitLimit = ITF8.readUnsignedITF8(buffer); return new BetaIntegerEncoding(offset, bitLimit); }
@Test(dataProvider = "bitsPerValue", expectedExceptions = IllegalArgumentException.class) public void bitsPerValue(final int bitsPerValue) { new BetaIntegerEncoding(0, bitsPerValue); } }
@DataProvider(name = "negativeConstructor") public static Object[][] negativeConstructor() { return new Object[][] { // mismatch type and encoding {DataSeriesType.BYTE, new BetaIntegerEncoding(0, 8).toParam()} }; }
@DataProvider(name = "negativeConstructor") public static Object[][] negativeConstructor() { return new Object[][] { // mismatch type and encoding {DataSeriesType.BYTE, new BetaIntegerEncoding(0, 8).toParam()} }; }
@Test(dataProvider = "tests") public void paramsTest(final int offset, final int bitLength, final byte[] expected) { final BetaIntegerEncoding constructed = new BetaIntegerEncoding(offset, bitLength); Assert.assertEquals(constructed.toByteArray(), expected); final BetaIntegerEncoding fromParams = BetaIntegerEncoding.fromParams(expected); Assert.assertEquals(fromParams.toByteArray(), expected); }
@Test(dataProvider = "tests") public void paramsTest(final int offset, final int bitsPerValue, final int externalBlockContentId, final byte[] expected) { // arbitrary choice here: any Integer, byte[] encoding pair will do final CRAMEncoding<Integer> constructedLength = new BetaIntegerEncoding(offset, bitsPerValue); final CRAMEncoding<byte[]> constructedValues = new ExternalByteArrayEncoding(externalBlockContentId); final ByteArrayLenEncoding constructed = new ByteArrayLenEncoding(constructedLength, constructedValues); Assert.assertEquals(constructed.toByteArray(), expected); final ByteArrayLenEncoding fromParams = ByteArrayLenEncoding.fromParams(expected); Assert.assertEquals(fromParams.toByteArray(), expected); } }