@Override protected ValueOption<?> newObject() { return new BooleanOption(); }
/** * test for initial state. */ @Test public void init() { BooleanOption option = new BooleanOption(); assertThat(option.isNull(), is(true)); }
/** * parse. */ @Test public void parse() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkParse(adapter, true, new BooleanOption(true)); checkParse(adapter, false, new BooleanOption(false)); }
/** * emit. */ @Test public void emit() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkEmit(adapter, new BooleanOption(true), true); checkEmit(adapter, new BooleanOption(false), false); }
/** * test for compare w/ null. */ @Test public void compareNull() { BooleanOption a = new BooleanOption(); BooleanOption b = new BooleanOption(); BooleanOption c = new BooleanOption(); a.modify(false); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }
/** * test for Writable w/ null. */ @Test public void writeNull() { BooleanOption option = new BooleanOption(); BooleanOption restored = restore(option); assertThat(restored.isNull(), is(true)); } }
/** * test for or w/ null. */ @Test public void or() { BooleanOption option = new BooleanOption(); assertThat(option.or(true), is(true)); assertThat(option.isNull(), is(true)); }
/** * test for or. */ @Test public void orNotNull() { BooleanOption option = new BooleanOption(); option.modify(true); assertThat(option.or(false), is(true)); }
/** * test for copyFrom. */ @Test public void copy() { BooleanOption option = new BooleanOption(); BooleanOption other = new BooleanOption(); other.modify(true); option.copyFrom(other); assertThat(option.get(), is(true)); option.modify(false); assertThat(other.get(), is(true)); }
/** * obtain value. */ @Test public void get() { BooleanOption option = new BooleanOption(); option.modify(false); assertThat(option.get(), is(false)); assertThat(option.isNull(), is(false)); }
/** * test for copyFrom w/ null. */ @Test public void copyNull() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption other = new BooleanOption(); option.copyFrom(other); assertThat(option.isNull(), is(true)); option.modify(true); option.copyFrom(null); assertThat(option.isNull(), is(true)); }
/** * emit - w/ format. */ @Test public void emit_format() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withTrueFormat("1") .withFalseFormat("0") .build(); checkEmit(adapter, new BooleanOption(true), "1"); checkEmit(adapter, new BooleanOption(false), "0"); } }
/** * parse - custom format. */ @Test public void parse_format() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withTrueFormat("1") .withFalseFormat("0") .build(); checkParse(adapter, 1, new BooleanOption(true)); checkParse(adapter, 0, new BooleanOption(false)); }
/** * emit - null. */ @Test public void emit_null() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkEmit(adapter, new BooleanOption(), null); }
/** * parse - null. */ @Test public void parse_null() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkParse(adapter, null, new BooleanOption()); }
/** * parse - empty. */ @Test public void parse_empty() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new BooleanOption()); }
/** * test for Writable. */ @Test public void writeTrue() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable. */ @Test public void writeFalse() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * parse - null formatted. */ @Test public void parse_null_formatted() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withNullFormat("") .build(); checkParse(adapter, "", new BooleanOption()); }
/** * emit - null formatted. */ @Test public void emit_null_formatted() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withNullFormat("") .build(); checkEmit(adapter, new BooleanOption(), ""); }