@Override protected ValueOption<?> newObject() { return new IntOption(); }
@SafeVarargs Mock(T... keys) { for (T key : keys) { entity.put(key, new IntOption()); } }
private List<IntOption> values(int...values) { List<IntOption> options = new ArrayList<>(); for (int value : values) { options.add(new IntOption(value)); } return sort(options); } }
/** * parse. */ @Test public void parse() { IntOptionFieldAdapter adapter = IntOptionFieldAdapter.builder().build(); checkParse(adapter, 0, new IntOption(0)); checkParse(adapter, 1, new IntOption(1)); checkParse(adapter, -1, new IntOption(-1)); checkParse(adapter, Integer.MAX_VALUE, new IntOption(Integer.MAX_VALUE)); checkParse(adapter, Integer.MIN_VALUE, new IntOption(Integer.MIN_VALUE)); }
private LookUpKey key(int... values) throws IOException { LookUpKey result = new LookUpKey(); for (int value : values) { result.add(new IntOption(value)); } return result; }
/** * parse - overflow. */ @Test public void parse_overflow() { IntOptionFieldAdapter adapter = IntOptionFieldAdapter.builder().build(); checkMalformed(adapter, BigInteger.valueOf(Integer.MAX_VALUE).add(BigInteger.ONE).toString(), new IntOption()); }
/** * test for initial state. */ @Test public void init() { IntOption option = new IntOption(); assertThat(option.isNull(), is(true)); }
/** * test for compare w/ null. */ @Test public void compareNull() { IntOption a = new IntOption(); IntOption b = new IntOption(); IntOption c = new IntOption(); a.modify(0x800000); 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() { IntOption option = new IntOption(); option.modify(100); assertThat(option.or(30), is(100)); }
/** * test for get. */ @Test public void get() { IntOption option = new IntOption(); option.modify(100); assertThat(option.get(), is(100)); assertThat(option.isNull(), is(false)); }
/** * emit - null. */ @Test public void emit_null() { IntOptionFieldAdapter adapter = IntOptionFieldAdapter.builder().build(); checkEmit(adapter, new IntOption(), null); }
/** * parse - empty. */ @Test public void parse_empty() { IntOptionFieldAdapter adapter = IntOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new IntOption()); }
/** * test for Writable w/ max. */ @Test public void write_max() { IntOption option = new IntOption(); option.modify(Integer.MAX_VALUE); IntOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable w/ zero. */ @Test public void write_0() { IntOption option = new IntOption(); option.modify(0); IntOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * parse - null. */ @Test public void parse_null() { IntOptionFieldAdapter adapter = IntOptionFieldAdapter.builder().withNullFormat("").build(); checkParse(adapter, "", new IntOption()); }
@SuppressWarnings("deprecation") private static int range(ListBuffer<IntOption> buffer, int begin, int end) { buffer.begin(); for (int i = begin; i < end; i++) { if (buffer.isExpandRequired()) { buffer.expand(new IntOption()); } buffer.advance().modify(i); } buffer.end(); return end - begin; }
/** * simple case. * @throws Exception if failed */ @Test public void simple() throws Exception { VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<>(); builder.add(key(100), new IntOption(100)); LookUpTable<IntOption> table = builder.build(); assertThat(sort(table.get(key(100))), is(values(100))); assertThat(sort(table.get(key(101))), is(values())); }