01: /*
02: Copyright 2004-2007 Paul R. Holser, Jr. All rights reserved.
03: Licensed under the Academic Free License version 3.0
04: */
05:
06: package joptsimple;
07:
08: import java.util.Collections;
09:
10: /**
11: * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
12: * @version $Id: WExtensionNoArgumentTest.java,v 1.14 2007/04/10 20:06:27 pholser Exp $
13: */
14: public class WExtensionNoArgumentTest extends
15: AbstractOptionParserFixture {
16: protected void setUp() throws Exception {
17: super .setUp();
18:
19: parser.accepts("silent");
20: parser.recognizeAlternativeLongOptions(true);
21: }
22:
23: public void testTurnOffWExtension() {
24: parser.recognizeAlternativeLongOptions(false);
25:
26: try {
27: parser.parse(new String[] { "-W", "silent" });
28: fail();
29: } catch (UnrecognizedOptionException expected) {
30: assertEquals("W", expected.option());
31: }
32: }
33:
34: public void testWExtensionWithLongOptionWithoutAnArgument() {
35: OptionSet options = parser
36: .parse(new String[] { "-W", "silent" });
37: assertOptionNotDetected(options, "W");
38: assertOptionDetected(options, "silent");
39: assertEquals(Collections.EMPTY_LIST, options
40: .argumentsOf("silent"));
41: assertEquals(Collections.EMPTY_LIST, options
42: .nonOptionArguments());
43: }
44: }
|