Def extends Token { public Def(final String name, final SingleValueExpression size, final Encoding encoding) { super(checkNotEmpty(name, "name"), encoding); this.size = checkNotNull(size, "size"); } Def(final String name, final SingleValueExpression size, final Encoding encoding); @Override String toString(); @Override boolean equals(final Object obj); @Override int hashCode(); final SingleValueExpression size; }
@Test public void scopeWithoutEncoding() { assertEquals(1, getValue(def("a", 1).parse(env("scope", stream(1), enc())).get().order, "scope.a").asNumeric().intValueExact()); }
@Test public void scopeWithEncoding() { assertEquals(1, getValue(def("a", 1, signed()).parse(env("scope", stream(1), enc())).get().order, "scope.a").asNumeric().intValueExact()); }
@Test public void errorEmptyName() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Argument name may not be empty."); def("", 1); }
@Test public void errorNegativeSize() { assertFalse(def("negativeSize", con(-1, signed())).parse(env(stream(1))).isPresent()); }