@Test
public void shouldHandleSmallint() throws Exception {

  Codec<Short> smallintCodec = mapper.codecFor(primitive(SMALLINT));
  assertThat(smallintCodec).isSameAs(mapper.smallint);
  encodeAndDecode(smallintCodec, (short) 0, "0x0000");
  encodeAndDecode(smallintCodec, Short.MAX_VALUE, "0x7fff");
  encodeAndDecode(smallintCodec, Short.MIN_VALUE, "0x8000");
  encodeAndDecode(smallintCodec, null, null, (short) 0);
  encodeObjectAndDecode(smallintCodec, (short) 1, "0x0001", (short) 1);
  encodeObjectAndDecode(smallintCodec, 1.0, "0x0001", (short) 1);
  encodeObjectAndDecode(smallintCodec, "1", "0x0001", (short) 1);
  encodeObjectAndDecode(smallintCodec, null, null, (short) 0);
  encodeObjectAndDecode(smallintCodec, Optional.of(12), null, (short) 0.0);
  try {
    // not enough bytes.
    smallintCodec.decode(Bytes.fromHexString("0x00"));
  } catch (InvalidTypeException e) {
    // expected
  }
}