Ejemplo n.º 1
0
int CommandOption_T::testCommandOptionGroupAnd()
{
    TestUtil  tester( "CommandOptionGroupAnd", "Initialization", __FILE__, __LINE__ );

    defaultCommandOptionList.clear();

    try
    {
        CommandOptionGroupAnd  cmdOpt;
        tester.assert( true, "CommandOptionGroupAnd was created successfully.", __LINE__ );
        tester.assert( (cmdOpt.getCount() == 0), "CommandOptionGroupAnd count should be 0.", __LINE__ );
        tester.assert( (cmdOpt.checkArguments().size() == 0), "CommandOptionGroupAnd checkArguments() should return nothing.", __LINE__ );
        tester.assert( (defaultCommandOptionList.size() == 1), "CommandOptionGroupAnd was not added to the default list.", __LINE__ );

        try
        {
            cmdOpt.addOption(NULL);
            tester.assert( false, "CommandOptionGroupAnd()::addOption() succeeded but should have failed due to an valid option address.", __LINE__ );
        }
        catch ( ... )
        {
            tester.assert( true, "CommandOptionGroupAnd::addOption() threw an exception as expected.", __LINE__ );
        }

        try
        {
            CommandOptionWithAnyArg  cowaa('f', "foo", "Foo", false);
            cmdOpt.addOption(&cowaa);
            tester.assert( true, "CommandOptionGroupAnd()::addOption() succeeded.", __LINE__ );
        }
        catch ( ... )
        {
            tester.assert( false, "CommandOptionGroupAnd::addOption() threw an exception but should not have.", __LINE__ );
        }
    }
    catch ( ... )
    {
        tester.assert( false, "CommandOptionGroupAnd() threw an exception but should not have.", __LINE__ );
    }
    defaultCommandOptionList.clear();

    return tester.countFails();
}