/** varchar. */
  @Test
  public void getVarchar() {
    ValueSerde serde = ValueSerdeFactory.getVarchar(10);
    HiveVarcharObjectInspector inspector = (HiveVarcharObjectInspector) serde.getInspector();

    StringOption option = new StringOption("hello");
    HiveVarchar value = new HiveVarchar("hello", 10);

    assertThat(inspector.copyObject(option), is((Object) option));
    assertThat(inspector.copyObject(option), is(not(sameInstance((Object) option))));
    assertThat(inspector.copyObject(null), is(nullValue()));
    // Note: HiveVarchar.equals(Object) is not defined, but equals(HiveVarchar) is defined
    assertThat(inspector.getPrimitiveJavaObject(option).equals(value), is(true));
    assertThat(inspector.getPrimitiveJavaObject(null), is(nullValue()));
    assertThat(inspector.getPrimitiveWritableObject(option), is(new HiveVarcharWritable(value)));
    assertThat(inspector.getPrimitiveWritableObject(null), is(nullValue()));

    ValueDriver driver = serde.getDriver(inspector);
    StringOption copy = new StringOption();

    driver.set(copy, option);
    assertThat(copy, is(option));
    driver.set(copy, null);
    assertThat(copy.isNull(), is(true));
  }
  /** qualified decimal. */
  @Test
  public void getDecimal() {
    ValueSerde serde = ValueSerdeFactory.getDecimal(10, 2);
    HiveDecimalObjectInspector inspector = (HiveDecimalObjectInspector) serde.getInspector();

    DecimalOption option = new DecimalOption(new BigDecimal("123.45"));
    HiveDecimal value = HiveDecimal.create(new BigDecimal("123.45"));

    assertThat(inspector.copyObject(option), is((Object) option));
    assertThat(inspector.copyObject(option), is(not(sameInstance((Object) option))));
    assertThat(inspector.copyObject(null), is(nullValue()));
    assertThat(inspector.getPrimitiveJavaObject(option), is(value));
    assertThat(inspector.getPrimitiveJavaObject(null), is(nullValue()));
    assertThat(inspector.getPrimitiveWritableObject(option), is(new HiveDecimalWritable(value)));
    assertThat(inspector.getPrimitiveWritableObject(null), is(nullValue()));

    ValueDriver driver = serde.getDriver(inspector);
    DecimalOption copy = new DecimalOption();

    driver.set(copy, option);
    assertThat(copy, is(option));
    driver.set(copy, null);
    assertThat(copy.isNull(), is(true));
  }
 /** constants. */
 @Test
 public void constants() {
   for (ValueSerdeFactory serde : ValueSerdeFactory.values()) {
     serde.getDriver(serde.getInspector());
   }
 }