public static byte[] packComparable(List<byte[]> arrays) { return packComparable( arrays, DEFAULT_DELIMITER, DEFAULT_TERMINAL_DELIMITER ); }
public static byte[] packComparable(byte[]... arrays) { return packComparable(Arrays.asList(arrays)); }
@Test(groups = "fast") public void testCompare1() throws Exception { // {2, 3, 3} byte[] bytes1 = PackedByteArray.packComparable( original[0] ); // {2, 3, 2} byte[] bytes2 = PackedByteArray.packComparable( original[1] ); // => -1 Assert.assertEquals(Lists.compareArrays(bytes1, bytes2), -1); }
@Test(groups = "fast") public void testCompare2() throws Exception { // { {0, 0, 1} } byte[] bytes1 = PackedByteArray.packComparable( original[1] ); // {{0, 1}, {0} } byte[] bytes2 = PackedByteArray.packComparable( original[5], original[6] ); // => 1 Assert.assertEquals(Lists.compareArrays(bytes1, bytes2), 1); }
@Test(groups = "fast") public void testConversions() throws Exception { byte[] packed = PackedByteArray.pack( original[0], original[1], original[2], original[3], original[4], original[5], original[6] ); byte[][] unpacked = PackedByteArray.unpack(packed); byte[] comparablePacked = PackedByteArray.packComparable(unpacked); List<byte[]> bytesList = PackedByteArray.unpackComparable(comparablePacked); for (int i = 0; i < unpacked.length; i++) { Assert.assertEquals(bytesList.get(i), unpacked[i]); } } }
@Test(groups = "fast") public void testCompare1() throws Exception { // {2, 3, 3} byte[] bytes1 = PackedByteArray.packComparable( original[0] ); // {2, 3, 2} byte[] bytes2 = PackedByteArray.packComparable( original[1] ); // => -1 Assert.assertEquals(Lists.compareArrays(bytes1, bytes2), -1); }
@Test(groups = "fast") public void testCompare2() throws Exception { // { {0, 0, 1} } byte[] bytes1 = PackedByteArray.packComparable( original[1] ); // {{0, 1}, {0} } byte[] bytes2 = PackedByteArray.packComparable( original[5], original[6] ); // => 1 Assert.assertEquals(Lists.compareArrays(bytes1, bytes2), 1); }
@Test(groups = "fast") public void testConversions() throws Exception { byte[] packed = PackedByteArray.pack( original[0], original[1], original[2], original[3], original[4], original[5], original[6] ); byte[][] unpacked = PackedByteArray.unpack(packed); byte[] comparablePacked = PackedByteArray.packComparable(unpacked); List<byte[]> bytesList = PackedByteArray.unpackComparable(comparablePacked); for (int i = 0; i < unpacked.length; i++) { Assert.assertEquals(bytesList.get(i), unpacked[i]); } } }