@Test public void resolvesAbbreviationToLongOption() { OptionSet options = parser.parse("-fo"); assertTrue(options.has("fox")); assertFalse(options.has("f")); assertFalse(options.has("o")); }
@Test public void singleLongOption() { OptionSet options = parser.parse("--verbose"); assertTrue(options.has("verbose")); assertEquals(emptyList(), options.valuesOf("verbose")); assertEquals(emptyList(), options.nonOptionArguments()); }
@Test public void resolvesToLongOptionWithSingleDashEvenWithMatchingShortOptions() { OptionSet options = parser.parse("-fox"); assertTrue(options.has("fox")); assertFalse(options.has("f")); assertFalse(options.has("o")); assertFalse(options.has("x")); }
@Test public void resolvesToShortOptionsWithArgumentFollowingX() { OptionSet options = parser.parse("-foxbar"); assertFalse(options.has("fox")); assertTrue(options.has("f")); assertTrue(options.has("o")); assertTrue(options.has("x")); assertEquals(singletonList("bar"), options.valuesOf("x")); }
@Override protected List<T> newList() { AbstractOptionSpec<T> spec = newOptionSpec(); OptionSet options = new OptionSet(emptyMap()); options.addWithArgument(spec, firstArg()); options.addWithArgument(spec, secondArg()); return spec.values(options); }
@Test public void abbreviationIsALegalOption() { OptionSet options = parser.parse("--verb"); assertFalse(options.has("verbose")); assertTrue(options.has("verb")); assertEquals(emptyList(), options.valuesOf("verb")); assertEquals(emptyList(), options.nonOptionArguments()); }
@Test public void abbreviation() { OptionSet options = parser.parse("--W", "silent"); assertOptionDetected(options, "Wally"); assertOptionNotDetected(options, "W"); assertEquals(singletonList("silent"), options.valuesOf("Wally")); assertEquals(emptyList(), options.nonOptionArguments()); }
@Test public void wExtensionWithLongOptionWithoutAnArgument() { OptionSet options = parser.parse("-W", "silent"); assertOptionNotDetected(options, "W"); assertOptionDetected(options, "silent"); assertEquals(emptyList(), options.valuesOf("silent")); assertEquals(emptyList(), options.nonOptionArguments()); }
@Test public void withArgumentComingAfterCluster() { OptionSet options = parser.parse("-fox", "bar"); assertTrue(options.has("fox")); assertFalse(options.has("f")); assertFalse(options.has("o")); assertFalse(options.has("x")); assertEquals(singletonList("bar"), options.nonOptionArguments()); }
@Test public void shortOptionsInDifferentOrder() { OptionSet options = parser.parse("-fxo"); assertFalse(options.has("fox")); assertTrue(options.has("f")); assertFalse(options.has("o")); assertTrue(options.has("x")); assertEquals(singletonList("o"), options.valuesOf("x")); }
@Test public void resolvesShortOptionToShortOptionEvenWithDoubleHyphen() { OptionSet options = parser.parse("--f"); assertFalse(options.has("fox")); assertTrue(options.has("f")); }
@Test public void resolvesShortOptionToShortOption() { OptionSet options = parser.parse("-f"); assertFalse(options.has("fox")); assertTrue(options.has("f")); }