/** * test for byte values. * @throws Exception if failed */ @Test public void byte_values_quote() throws Exception { quote.add(0); assertRestorable(new ByteOption((byte) 0)); assertRestorable(new ByteOption((byte) 1)); assertRestorable(new ByteOption((byte) -1)); assertRestorable(new ByteOption()); }
/** * parse. */ @Test public void parse() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().build(); checkParse(adapter, 0, new ByteOption((byte) 0)); checkParse(adapter, 1, new ByteOption((byte) 1)); checkParse(adapter, -1, new ByteOption((byte) -1)); checkParse(adapter, Byte.MAX_VALUE, new ByteOption(Byte.MAX_VALUE)); checkParse(adapter, Byte.MIN_VALUE, new ByteOption(Byte.MIN_VALUE)); }
/** * parse - overflow. */ @Test public void parse_overflow() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().build(); checkMalformed(adapter, BigInteger.valueOf(Byte.MAX_VALUE).add(BigInteger.ONE).toString(), new ByteOption()); }
/** * test for initial state. */ @Test public void init() { ByteOption option = new ByteOption(); assertThat(option.isNull(), is(true)); }
/** * emit. */ @Test public void emit() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().build(); checkEmit(adapter, new ByteOption((byte) 1), 1); checkEmit(adapter, new ByteOption((byte) -1), -1); }
/** * test for compare w/ null. */ @Test public void compareNull() { ByteOption a = new ByteOption(); ByteOption b = new ByteOption(); ByteOption c = new ByteOption(); a.modify((byte) 0x80); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }
/** * test for or w/ null. */ @Test public void or() { ByteOption option = new ByteOption(); assertThat(option.or((byte) 30), is((byte) 30)); assertThat(option.isNull(), is(true)); }
/** * test for or. */ @Test public void orNotNull() { ByteOption option = new ByteOption(); option.modify((byte) 100); assertThat(option.or((byte) 30), is((byte) 100)); }
/** * test for Writable w/ null. */ @Test public void writeNull() { ByteOption option = new ByteOption(); ByteOption restored = restore(option); assertThat(restored.isNull(), is(true)); } }
/** * test for copyFrom. */ @Test public void copy() { ByteOption option = new ByteOption(); ByteOption other = new ByteOption(); other.modify((byte) 50); option.copyFrom(other); assertThat(option.get(), is((byte) 50)); option.modify((byte) 0); assertThat(other.get(), is((byte) 50)); }
/** * test for get. */ @Test public void get() { ByteOption option = new ByteOption(); option.modify((byte) 100); assertThat(option.get(), is((byte) 100)); assertThat(option.isNull(), is(false)); }
/** * test for copyFrom w/ null. */ @Test public void copyNull() { ByteOption option = new ByteOption(); option.modify((byte) 100); ByteOption other = new ByteOption(); option.copyFrom(other); assertThat(option.isNull(), is(true)); option.modify((byte) 100); option.copyFrom(null); assertThat(option.isNull(), is(true)); }
/** * parse - empty. */ @Test public void parse_empty() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new ByteOption()); }
/** * emit - null. */ @Test public void emit_null() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().build(); checkEmit(adapter, new ByteOption(), null); }
/** * test for Writable. */ @Test public void write_max() { ByteOption option = new ByteOption(); option.modify(Byte.MAX_VALUE); ByteOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * date placeholder. * @throws Exception if failed */ @Test public void placeholder_byte() throws Exception { Mock mock = new Mock(spec(BYTE, "0000")); mock.setMock(new ByteOption((byte) 1)); assertThat(mock.apply(), is("0001")); }
/** * test for Writable. */ @Test public void write() { ByteOption option = new ByteOption(); option.modify((byte) 100); ByteOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable. */ @Test public void write_min() { ByteOption option = new ByteOption(); option.modify(Byte.MIN_VALUE); ByteOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * parse - null. */ @Test public void parse_null() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().withNullFormat("").build(); checkParse(adapter, "", new ByteOption()); }
/** * emit - null w/ format. */ @Test public void emit_null_formatted() { ByteOptionFieldAdapter adapter = ByteOptionFieldAdapter.builder().withNullFormat("").build(); checkEmit(adapter, new ByteOption(), ""); }