Skip to content

Commit d029367

Browse files
committed
Added a test for parsing negative values with GnuParser
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/branches/cli-1.x@661807 13f79535-47bb-0310-9956-ffa450edef68
1 parent 3d11b55 commit d029367

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/test/org/apache/commons/cli/GnuParseTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
package org.apache.commons.cli;
1819

1920
import junit.framework.TestCase;
@@ -192,4 +193,16 @@ public void testSingleDash() throws Exception
192193
assertTrue( "Confirm 1 extra arg: " + cl.getArgList().size(), cl.getArgList().size() == 1);
193194
assertTrue( "Confirm value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("-") );
194195
}
196+
197+
public void testNegativeArgument() throws Exception
198+
{
199+
String[] args = new String[] { "-a", "-1"} ;
200+
201+
Options options = new Options();
202+
options.addOption(OptionBuilder.hasArg().create("a"));
203+
204+
Parser parser = new GnuParser();
205+
CommandLine cl = parser.parse(options, args);
206+
assertEquals("-1", cl.getOptionValue("a"));
207+
}
195208
}

0 commit comments

Comments
 (0)