File tree Expand file tree Collapse file tree
src/test/org/apache/commons/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414 * See the License for the specific language governing permissions and
1515 * limitations under the License.
1616 */
17+
1718package org .apache .commons .cli ;
1819
1920import 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}
You can’t perform that action at this time.
0 commit comments