@Override protected ValueOption<?> newObject() { return new DoubleOption(); }
/** * test for double values. * @throws Exception if failed */ @Test public void double_values_quote() throws Exception { quote.add(0); assertRestorable(new DoubleOption(0)); assertRestorable(new DoubleOption(1)); assertRestorable(new DoubleOption(-1)); }
/** * emit. */ @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 for initial state. */ @Test public void init() { DoubleOption option = new DoubleOption(); assertThat(option.isNull(), is(true)); }
/** * test for compare w/ null. */ @Test public void compareNull() { DoubleOption a = new DoubleOption(); DoubleOption b = new DoubleOption(); DoubleOption c = new DoubleOption(); a.modify(Double.NEGATIVE_INFINITY); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }
/** * test for or w/ present value. */ @Test public void orNotNull() { DoubleOption option = new DoubleOption(); option.modify(100); assertThat(option.or(30), is(100.d)); }
/** * test for Writable w/ null. */ @Test public void writeNull() { DoubleOption option = new DoubleOption(); DoubleOption restored = restore(option); assertThat(restored.isNull(), is(true)); } }
/** * test for or w/ absent value. */ @Test public void or() { DoubleOption option = new DoubleOption(); assertThat(option.or(30), is(30.d)); assertThat(option.isNull(), is(true)); }
/** * test for copyFrom. */ @Test public void copy() { DoubleOption option = new DoubleOption(); DoubleOption other = new DoubleOption(); other.modify(50); option.copyFrom(other); assertThat(option.get(), is(50.d)); option.modify(0); assertThat(other.get(), is(50.d)); }
/** * test for copyFrom w/ null. */ @Test public void copyNull() { DoubleOption option = new DoubleOption(); option.modify(100); DoubleOption other = new DoubleOption(); option.copyFrom(other); assertThat(option.isNull(), is(true)); option.modify(100); option.copyFrom(null); assertThat(option.isNull(), is(true)); }
/** * test for get. */ @Test public void get() { DoubleOption option = new DoubleOption(); option.modify(100); assertThat(option.get(), is(100.d)); assertThat(option.isNull(), is(false)); }
/** * parse - malformed. */ @Test public void parse_malformed() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkMalformed(adapter, "A", new DoubleOption()); }
/** * parse - empty. */ @Test public void parse_empty() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new DoubleOption()); }
/** * emit - null. */ @Test public void emit_null() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().build(); checkEmit(adapter, new DoubleOption(), null); }
/** * test for Writable. */ @Test public void write() { DoubleOption option = new DoubleOption(); option.modify(100); DoubleOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable w/ max. */ @Test public void write_max() { DoubleOption option = new DoubleOption(); option.modify(Double.POSITIVE_INFINITY); DoubleOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * double placeholder. * @throws Exception if failed */ @Test public void placeholder_double() throws Exception { Mock mock = new Mock(spec(DOUBLE, "0000")); mock.setMock(new DoubleOption(1)); assertThat(mock.apply(), is("0001")); }
/** * test for Writable w/ min. */ @Test public void write_min() { DoubleOption option = new DoubleOption(); option.modify(Double.NEGATIVE_INFINITY); DoubleOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * parse - null. */ @Test public void parse_null() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().withNullFormat("").build(); checkParse(adapter, "", new DoubleOption()); }
/** * emit - null w/ format. */ @Test public void emit_null_formatted() { DoubleOptionFieldAdapter adapter = DoubleOptionFieldAdapter.builder().withNullFormat("").build(); checkEmit(adapter, new DoubleOption(), ""); }