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: WAsShortOptionTest.java,v 1.14 2007/04/10 20:06:27 pholser Exp $
13: */
14: public class WAsShortOptionTest extends AbstractOptionParserFixture {
15: protected void setUp() throws Exception {
16: super .setUp();
17:
18: parser.accepts("W");
19: }
20:
21: public void testWIsLegal() {
22: OptionSet options = parser
23: .parse(new String[] { "-W", "silent" });
24: assertOptionDetected(options, "W");
25: assertEquals(Collections.EMPTY_LIST, options.argumentsOf("W"));
26: assertEquals(Collections.singletonList("silent"), options
27: .nonOptionArguments());
28: }
29:
30: public void testRecognizeLongOptionsTrumpsShortOptionW() {
31: parser.recognizeAlternativeLongOptions(true);
32:
33: try {
34: parser.parse(new String[] { "-W", "silent" });
35: fail();
36: } catch (UnrecognizedOptionException expected) {
37: assertEquals("silent", expected.option());
38: }
39: }
40: }
|