avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/cli/src/test/org/apache/avalon/excalibur/cli/test ClutilTestCase.java
Date Tue, 19 Mar 2002 11:58:07 GMT
donaldp     02/03/19 03:58:07

  Modified:    cli/src/test/org/apache/avalon/excalibur/cli/test
                        ClutilTestCase.java
  Log:
  Add in test case to make sure options with optional args can have a space after option and
before arg
  
  Revision  Changes    Path
  1.13      +29 -5     jakarta-avalon-excalibur/cli/src/test/org/apache/avalon/excalibur/cli/test/ClutilTestCase.java
  
  Index: ClutilTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/cli/src/test/org/apache/avalon/excalibur/cli/test/ClutilTestCase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ClutilTestCase.java	19 Mar 2002 11:04:02 -0000	1.12
  +++ ClutilTestCase.java	19 Mar 2002 11:58:07 -0000	1.13
  @@ -122,6 +122,34 @@
           test.testShortOptArgUnenteredBeforeOtherOpt();
       }
   
  +    public void testOptionalArgWithSpace()
  +    {
  +        final CLOptionDescriptor[] options = new CLOptionDescriptor[]
  +        {
  +            ALL, TAINT
  +        };
  +
  +        final String[] args = new String[]{"-T", "param", "-a"};
  +
  +        final CLArgsParser parser = new CLArgsParser( args, options );
  +
  +        assertNull( parser.getErrorString(), parser.getErrorString() );
  +
  +        final List clOptions = parser.getArguments();
  +        final int size = clOptions.size();
  +
  +        assertEquals( "Option count", 2, size );
  +
  +        final CLOption option0 = (CLOption)clOptions.get( 0 );
  +        assertEquals( "Option Code: " + option0.getId(), TAINT_OPT, option0.getId() );
  +        assertEquals( "Option Arg: " + option0.getArgument( 0 ),
  +                      "param", option0.getArgument( 0 ) );
  +
  +        final CLOption option1 = (CLOption)clOptions.get( 1 );
  +        assertEquals( option1.getId(), ALL_OPT );
  +        assertEquals( option1.getArgument( 0 ), null );
  +    }
  +
       public void testShortOptArgUnenteredBeforeOtherOpt()
       {
           final CLOptionDescriptor[] options = new CLOptionDescriptor[]
  @@ -131,17 +159,14 @@
   
           final String[] args = new String[]{"-T", "-a"};
   
  -        //System.out.println("[before parsing]");
           final CLArgsParser parser = new CLArgsParser( args, options );
  -        //System.out.println("[after parsing]");
   
           assertNull( parser.getErrorString(), parser.getErrorString() );
   
           final List clOptions = parser.getArguments();
           final int size = clOptions.size();
   
  -        //System.out.println( new StringBuffer("clOptions: ").append(clOptions) );
  -        assertEquals( size, 2 );
  +        assertEquals( "Option count", 2, size );
   
           final CLOption option0 = (CLOption)clOptions.get( 0 );
           assertEquals( "Option Code: " + option0.getId(), TAINT_OPT, option0.getId() );
  @@ -194,7 +219,6 @@
           final String[] args = new String[]{"-T", "-a"};
   
           //System.out.println("[before parsing]");
  -
           final CLArgsParser parser = new CLArgsParser( args, options );
   
           //System.out.println("[after parsing]");
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message