@Test
public void shouldHandleBoolean() {

  Codec<Boolean> booleanCodec = mapper.codecFor(primitive(BOOLEAN));
  assertThat(booleanCodec).isSameAs(mapper.bool);
  encodeAndDecode(booleanCodec, true, "0x01");
  encodeAndDecode(booleanCodec, false, "0x00");
  encodeAndDecode(booleanCodec, null, null, false);
  encodeObjectAndDecode(booleanCodec, false, "0x00", false);
  encodeObjectAndDecode(booleanCodec, "TRUE", "0x01", true);
  encodeObjectAndDecode(booleanCodec, 2, "0x01", true);
  encodeObjectAndDecode(booleanCodec, null, null, false);
  encodeObjectAndDecode(booleanCodec, Optional.of(12), null, false);
  try {
    // too many bytes
    booleanCodec.decode(Bytes.fromHexString("0x0100"));
  } catch (InvalidTypeException e) {
    // expected
  }
  // empty bytebuf should yield false.
  assertThat(booleanCodec.decode(Bytes.fromHexString("0x"))).isEqualTo(false);
}