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: SingleHyphenTest.java,v 1.12 2007/04/10 20:06:26 pholser Exp $
13: */
14: public class SingleHyphenTest extends AbstractOptionParserFixture {
15: protected void setUp() throws Exception {
16: super .setUp();
17:
18: parser.accepts("o").withOptionalArg();
19: }
20:
21: public void testSingleHyphen() {
22: OptionSet options = parser.parse(new String[] { "-" });
23: assertEquals(Collections.singletonList("-"), options
24: .nonOptionArguments());
25: }
26:
27: public void testAsArgumentOfOption() {
28: OptionSet options = parser.parse(new String[] { "-o", "-" });
29: assertOptionDetected(options, "o");
30: assertEquals(Collections.singletonList("-"), options
31: .argumentsOf("o"));
32: assertEquals(Collections.EMPTY_LIST, options
33: .nonOptionArguments());
34: }
35:
36: public void testAsArgumentOfOptionInSameToken() {
37: OptionSet options = parser.parse(new String[] { "-o-" });
38: assertOptionDetected(options, "o");
39: assertEquals(Collections.singletonList("-"), options
40: .argumentsOf("o"));
41: assertEquals(Collections.EMPTY_LIST, options
42: .nonOptionArguments());
43: }
44: }
|