Serializer { public void writeBoolean(boolean b) { BigEndianCodec.putBoolean(_getBuffer(1), _index++, b); } Serializer(); ByteBuffer toByteBuffer(); void writeBoolean(boolean b); void writeByte(byte b); void writeChar(char c); void writeDouble(double d); void writeFloat(float f); void writeInt(int i); void writeLong(long l); void writeObject(Serializable serializable); void writeShort(short s); void writeString(String s); void writeTo(OutputStream outputStream);  }
@Test public void testWriteBoolean() throws Exception { Serializer serializer = new Serializer(); boolean[] booleans = new boolean[_COUNT]; for (int i = 0; i < _COUNT; i++) { booleans[i] = _random.nextBoolean(); serializer.writeBoolean(booleans[i]); } ByteBuffer byteBuffer = serializer.toByteBuffer(); byte[] bytes = byteBuffer.array(); Assert.assertNull(_bufferField.get(serializer)); for (int i = 0; i < _COUNT; i++) { if (booleans[i]) { Assert.assertEquals(1, bytes[i]); } else { Assert.assertEquals(0, bytes[i]); } } }