### Question:
DoubleOptionFieldAdapter extends NumericOptionFieldAdapter<DoubleOption> { public static Builder builder() { return new Builder(); } DoubleOptionFieldAdapter(String nullFormat, DecimalFormat decimalFormat); static Builder builder();  }### Answer:
@Test public void parse() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkParse(adapter, 0.d, new DoubleOption(0)); checkParse(adapter, 1.d, new DoubleOption(1)); checkParse(adapter, -1.d, new DoubleOption(-1)); checkParse(adapter, Double.NaN, new DoubleOption(Double.NaN)); checkParse(adapter, Double.POSITIVE_INFINITY, new DoubleOption(Double.POSITIVE_INFINITY)); checkParse(adapter, Double.NEGATIVE_INFINITY, new DoubleOption(Double.NEGATIVE_INFINITY)); }
@Test public void parse_malformed() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkMalformed(adapter, "A", new DoubleOption()); }
@Test public void parse_empty() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new DoubleOption()); }
@Test public void parse_null() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().withNullFormat("").build(); checkParse(adapter, "", new DoubleOption()); }
@Test public void emit() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkEmit(adapter, new DoubleOption(0), 0.d); checkEmit(adapter, new DoubleOption(1), 1.d); checkEmit(adapter, new DoubleOption(-1), -1.d); }
@Test public void emit_null() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkEmit(adapter, new DoubleOption(), null); }
@Test public void emit_null_formatted() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().withNullFormat("").build(); checkEmit(adapter, new DoubleOption(), ""); }
@Test public void number_format() { DecimalFormatSymbols syms = DecimalFormatSymbols.getInstance(); DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder() .withNumberFormat("0.00") .withDecimalFormatSymbols(syms) .build(); checkParse(adapter, 0, new DoubleOption(0)); checkParse(adapter, 1, new DoubleOption(1)); checkParse(adapter, -1, new DoubleOption(-1)); checkParse(adapter, "-0", new DoubleOption(0)); checkParse(adapter, syms.getNaN(), new DoubleOption(Double.NaN)); checkParse(adapter, syms.getInfinity(), new DoubleOption(Double.POSITIVE_INFINITY)); checkParse(adapter, "-" + syms.getInfinity(), new DoubleOption(Double.NEGATIVE_INFINITY)); checkMalformed(adapter, "", new DoubleOption()); checkMalformed(adapter, "Hello, world!", new DoubleOption()); checkEmit(adapter, new DoubleOption(1), "1.00"); checkEmit(adapter, new DoubleOption(-1), "-1.00"); checkEmit(adapter, new DoubleOption(Math.PI), "3.14"); checkEmit(adapter, new DoubleOption(12345), "12345.00"); checkEmit(adapter, new DoubleOption(-0), "0.00"); checkEmit(adapter, new DoubleOption(Double.NaN), syms.getNaN()); checkEmit(adapter, new DoubleOption(Double.POSITIVE_INFINITY), syms.getInfinity()); checkEmit(adapter, new DoubleOption(Double.NEGATIVE_INFINITY), "-" + syms.getInfinity()); }