@Test public void testNoArgs() { checkArgLimits(null, 0, 0); checkArgLimits(null, 0, 1); checkArgLimits(NotEnoughArgumentsException.class, 1, 1); checkArgLimits(NotEnoughArgumentsException.class, 1, 2); }
@Test public void testOneArg() { args = listOf("a"); expectedArgs = listOf("a"); checkArgLimits(TooManyArgumentsException.class, 0, 0); checkArgLimits(null, 0, 1); checkArgLimits(null, 1, 1); checkArgLimits(null, 1, 2); checkArgLimits(NotEnoughArgumentsException.class, 2, 3); }
@Test public void testTwoArgs() { args = listOf("a", "b"); expectedArgs = listOf("a", "b"); checkArgLimits(TooManyArgumentsException.class, 0, 0); checkArgLimits(TooManyArgumentsException.class, 1, 1); checkArgLimits(null, 1, 2); checkArgLimits(null, 2, 2); checkArgLimits(null, 2, 3); checkArgLimits(NotEnoughArgumentsException.class, 3, 3); }
@Test public void testOneOpt() { args = listOf("-a"); expectedOpts = setOf("a"); checkArgLimits(UnknownOptionException.class, 0, 0); checkArgLimits(null, 0, 0, "a", "b"); checkArgLimits(NotEnoughArgumentsException.class, 1, 1, "a", "b"); }
@Test public void testTwoOpts() { args = listOf("-a", "-b"); expectedOpts = setOf("a", "b"); checkArgLimits(UnknownOptionException.class, 0, 0); checkArgLimits(null, 0, 0, "a", "b"); checkArgLimits(null, 0, 1, "a", "b"); checkArgLimits(NotEnoughArgumentsException.class, 1, 1, "a", "b"); }
@Test public void testOptArg() { args = listOf("-a", "b"); expectedOpts = setOf("a"); expectedArgs = listOf("b"); checkArgLimits(UnknownOptionException.class, 0, 0); checkArgLimits(TooManyArgumentsException.class, 0, 0, "a", "b"); checkArgLimits(null, 0, 1, "a", "b"); checkArgLimits(null, 1, 1, "a", "b"); checkArgLimits(null, 1, 2, "a", "b"); checkArgLimits(NotEnoughArgumentsException.class, 2, 2, "a", "b"); }
@Test public void testArgOpt() { args = listOf("b", "-a"); expectedArgs = listOf("b", "-a"); checkArgLimits(TooManyArgumentsException.class, 0, 0, "a", "b"); checkArgLimits(null, 1, 2, "a", "b"); checkArgLimits(null, 2, 2, "a", "b"); checkArgLimits(NotEnoughArgumentsException.class, 3, 4, "a", "b"); }
@Test public void testOptStopOptArg() { args = listOf("-a", "--", "-b", "c"); expectedOpts = setOf("a"); expectedArgs = listOf("-b", "c"); checkArgLimits(UnknownOptionException.class, 0, 0); checkArgLimits(TooManyArgumentsException.class, 0, 1, "a", "b"); checkArgLimits(null, 2, 2, "a", "b"); checkArgLimits(NotEnoughArgumentsException.class, 3, 4, "a", "b"); }
@Test public void testOptDashArg() { args = listOf("-b", "-", "-c"); expectedOpts = setOf("b"); expectedArgs = listOf("-", "-c"); checkArgLimits(UnknownOptionException.class, 0, 0); checkArgLimits(TooManyArgumentsException.class, 0, 0, "b", "c"); checkArgLimits(TooManyArgumentsException.class, 1, 1, "b", "c"); checkArgLimits(null, 2, 2, "b", "c"); checkArgLimits(NotEnoughArgumentsException.class, 3, 4, "b", "c"); }
@Test public void processOptionsMissingArgs() { LinkedList<String> options = new LinkedList<String>(); Count count = new Count(); try { count.processOptions(options); fail("Count.processOptions - NotEnoughArgumentsException not thrown"); } catch (NotEnoughArgumentsException e) { } assertFalse(count.isShowQuotas()); }