### Question:
DecimalOptionFieldAdapter extends NumericOptionFieldAdapter<DecimalOption> { public static Builder builder() { return new Builder(); } DecimalOptionFieldAdapter(String nullFormat, DecimalFormat decimalFormat, OutputStyle outputStyle); static Builder builder(); static final OutputStyle DEFAULT_OUTPUT_STYLE; }### Answer:
@Test public void parse() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkParse(adapter, 0, new DecimalOption(d("0"))); checkParse(adapter, "12345.67890", new DecimalOption(d("12345.67890"))); }
@Test public void parse_malform() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkMalformed(adapter, "Hello, world!", new DecimalOption()); }
@Test public void parse_empty() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new DecimalOption()); }
@Test public void parse_null() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder() .withNullFormat("") .build(); checkParse(adapter, "", new DecimalOption()); }
@Test public void emit() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkEmit(adapter, new DecimalOption(d("0")), "0"); checkEmit(adapter, new DecimalOption(d("12345.67890")), "12345.67890"); }
@Test public void emit_null() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkEmit(adapter, new DecimalOption(), null); }
@Test public void emit_null_formatted() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder() .withNullFormat("") .build(); checkEmit(adapter, new DecimalOption(), ""); }
@Test public void emit_default_style() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder().build(); checkEmit(adapter, new DecimalOption(new BigDecimal(BigInteger.valueOf(12), -10)), "1.2E+11"); }
@Test public void emit_plain() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder() .withOutputStyle(OutputStyle.PLAIN) .build(); checkEmit(adapter, new DecimalOption(new BigDecimal(BigInteger.valueOf(12), -10)), "120000000000"); }
@Test public void emit_engineering() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder() .withOutputStyle(OutputStyle.ENGINEERING) .build(); checkEmit(adapter, new DecimalOption(new BigDecimal(BigInteger.valueOf(12), -10)), "120E+9"); }
@Test public void number_format() { DecimalOptionFieldAdapter adapter = DecimalOptionFieldAdapter.builder() .withNumberFormat("0.00") .build(); checkParse(adapter, 0, new DecimalOption(d("0"))); checkParse(adapter, 1, new DecimalOption(d("1"))); checkParse(adapter, -1, new DecimalOption(d("-1"))); checkMalformed(adapter, "", new DecimalOption()); checkMalformed(adapter, "Hello, world!", new DecimalOption()); checkEmit(adapter, new DecimalOption(d("1")), "1.00"); checkEmit(adapter, new DecimalOption(d("-1")), "-1.00"); checkEmit(adapter, new DecimalOption(d("3.1415")), "3.14"); checkEmit(adapter, new DecimalOption(d("12345")), "12345.00"); }