@Test
public void shouldHandleDecimal() {

  Codec<BigDecimal> decimalCodec = mapper.codecFor(primitive(DECIMAL));
  assertThat(decimalCodec).isSameAs(mapper.decimal);
  encodeAndDecode(
      decimalCodec, new BigDecimal(8675e39), "0x00000000639588a2c184700000000000000000000000");
  encodeAndDecode(decimalCodec, new BigDecimal(0), "0x0000000000");
  encodeAndDecode(decimalCodec, null, null);
  encodeObjectAndDecode(
      decimalCodec,
      new BigDecimal(8675e39),
      "0x00000000639588a2c184700000000000000000000000",
      new BigDecimal(8675e39));
  encodeObjectAndDecode(decimalCodec, null, null, null);
  encodeObjectAndDecode(decimalCodec, 5, "0x0000000005", new BigDecimal(5));
  encodeObjectAndDecode(decimalCodec, "5", "0x0000000005", new BigDecimal(5));
  encodeObjectAndDecode(decimalCodec, Optional.of(12), null, null);
  try {
    // not enough bytes.
    decimalCodec.decode(Bytes.fromHexString("0x00ffef"));
  } catch (InvalidTypeException e) {
    // expected
  }
}