@Test @SuppressWarnings("deprecation") public void testStringConstructors() { String[] args = new String[] {"1", "2", "3"}; CommandLine c1 = new CommandLine(args); Assert.assertEquals(null, c1.getCommandName()); Assert.assertEquals(null, c1.getCommandToken()); SymbolSource<String> ss = c1.iterator(); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("1", ss.next()); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("2", ss.next()); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("3", ss.next()); Assert.assertEquals(false, ss.hasNext()); SymbolSource<Token> ts = c1.tokenIterator(); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals("1", ts.next().text); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals("2", ts.next().text); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals("3", ts.next().text); Assert.assertEquals(false, ts.hasNext()); CommandLine c2 = new CommandLine("foo", args); Assert.assertEquals("foo", c2.getCommandName()); Assert.assertEquals("foo", c2.getCommandToken().text); }
@Test @SuppressWarnings("deprecation") public void testTokenConstructors() { Token foo = new Token("foo"); Token[] args = new Token[] {new Token("1"), new Token("2"), new Token("3")}; CommandLine c1 = new CommandLine(foo, args, null); Assert.assertEquals("foo", c1.getCommandName()); Assert.assertEquals(foo, c1.getCommandToken()); SymbolSource<String> ss = c1.iterator(); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("1", ss.next()); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("2", ss.next()); Assert.assertEquals(true, ss.hasNext()); Assert.assertEquals("3", ss.next()); Assert.assertEquals(false, ss.hasNext()); SymbolSource<Token> ts = c1.tokenIterator(); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals(args[0], ts.next()); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals(args[1], ts.next()); Assert.assertEquals(true, ts.hasNext()); Assert.assertEquals(args[2], ts.next()); Assert.assertEquals(false, ts.hasNext()); }