ArgHelperOptionsInfoTestpublic class ArgHelperOptionsInfoTest extends TestCase
Constructors Summary |
---|
public ArgHelperOptionsInfoTest()
|
Methods Summary |
---|
void | checkCreateFailure(java.lang.String options)
try
{
new ArgHelperOptionsInfo( options );
fail( "expected failure from option description \"" + options + "\"" );
}
catch( Exception e )
{
// good
}
| void | checkRedundantFailure(java.lang.String args)
try
{
new ArgHelperOptionsInfo( args );
fail( "expected rejection of redundant option" );
}
catch( Exception e )
{
}
| public void | setUp()
| public void | tearDown()
| public void | testCreate()
new ArgHelperOptionsInfo();
new ArgHelperOptionsInfo( "a b c" );
new ArgHelperOptionsInfo( "aa bb,2 cc" );
new ArgHelperOptionsInfo( "long-option-dashed-name" );
new ArgHelperOptionsInfo( "long.option.dotted.name" );
new ArgHelperOptionsInfo( "long_option_underscore_name" );
new ArgHelperOptionsInfo( "long-option_mixed.name" );
| public void | testCreateFailures()
final String illegals = "~`!@#$%^&*()+={}[]|\\:;\"'<>?,/";
for( int i = 0; i < illegals.length(); ++i )
{
checkCreateFailure( "" + illegals.charAt( i ) );
}
| public void | testIllegals()
final ArgHelperOptionsInfo info = new ArgHelperOptionsInfo( "hello h" );
assertEquals( false, info.isLegalOption( "hello" ) );
assertEquals( false, info.isLegalOption( "-hello" ) );
assertEquals( false, info.isLegalOption( "h" ) );
assertEquals( false, info.isLegalOption( "--h" ) );
assertEquals( false, info.isLegalOption( "-" ) );
assertEquals( false, info.isLegalOption( "--" ) );
assertEquals( false, info.isLegalOption( "" ) );
| public void | testLegals()
final ArgHelperOptionsInfo info = new ArgHelperOptionsInfo( "hello --there,3 x,1 -y,1" );
assertEquals( true, info.isLegalOption( "--hello" ) );
assertEquals( true, info.isLegalOption( "--there" ) );
assertEquals( true, info.isLegalOption( "-x" ) );
assertEquals( true, info.isLegalOption( "-y" ) );
| public void | testMixedArgs()
final ArgHelperOptionsInfo info = new ArgHelperOptionsInfo( "a b,1 c,2 d,3 --xyz,4" );
assertEquals( true, info.isLegalOption( "-a" ) );
assertEquals( false, info.isLegalOption( "--a" ) );
assertEquals( 1, info.getNumValues( "-a" ) );
assertEquals( true, info.isBoolean( "-a" ) );
assertEquals( 1, info.getNumValues( "-b" ) );
assertEquals( 2, info.getNumValues( "-c" ) );
assertEquals( 3, info.getNumValues( "-d" ) );
assertEquals( 4, info.getNumValues( "--xyz" ) );
| public void | testRedundant()
checkRedundantFailure( "a a" );
checkRedundantFailure( "aa aa" );
checkRedundantFailure( "--aa --aa" );
checkRedundantFailure( "-a -a" );
|
|