BooleanArrayAdapter extends TypeAdapter<boolean[]> { @Override public boolean[] deserialize(byte[] array, int pos) { int cursor = pos; int length = Serialization.readInt(array, cursor); cursor += Serialization.SIZE_OF_INT; boolean[] booleanArray = new boolean[length]; for (int i = 0; i < length; i++) { boolean bool = Serialization.readBoolean(array, cursor); booleanArray[i] = bool; cursor += Serialization.SIZE_OF_BOOL; } return booleanArray; } BooleanArrayAdapter(); @Override byte[] serialize(boolean[] array); @Override boolean[] deserialize(byte[] array, int pos); @Override int getSerializedSize(boolean[] value);  }
@Test public void testDecodeEmptyArray() { final byte[] buffer = {0, 0, 0, 0}; final boolean[] deserialized = adapter.deserialize(buffer, 0); assertEquals(0, deserialized.length); }
@Test public void testDecode() { final byte[] buffer = {0, 0, 0, 4, 1, 0, 1, 0}; final boolean[] expected = {true, false, true, false}; assertArrayEquals(expected, adapter.deserialize(buffer, 0)); }