MOAB: Mesh Oriented datABase  (version 5.2.1)
msq_test_main.cpp File Reference
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include <cppunit/Outputter.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestFailure.h>
#include <cppunit/Test.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include "MsqFPE.hpp"
+ Include dependency graph for msq_test_main.cpp:

Go to the source code of this file.

Classes

class  SummaryOutput

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 55 of file msq_test_main.cpp.

References test.

{
    CppUnit::Test* test;
    vector< CppUnit::Test* > test_list;
    CppUnit::TextUi::TestRunner runner;
    int firsttest = 1;
    bool list     = false;
    MBMesquite::MsqFPE trap_fpe( true );

    // Check for command line arguments
    if( argc > 2 && !strcmp( argv[1], "-s" ) )
    {
        FILE* file = fopen( argv[2], "w" );
        if( !file )
        {
            perror( argv[2] );
            exit( 1 );
        }
        runner.setOutputter( new SummaryOutput( file, &runner.result() ) );
        firsttest += 2;
    }
    else if( argc > 1 && !strcmp( argv[1], "-l" ) )
    {
        ++firsttest;
        list = true;
    }

    // If the user requested a specific test...
    if( argc > firsttest )
    {
        while( argc > firsttest )
        {
            argc--;
            CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry( argv[argc] );
            test                                   = registry.makeTest();
            if( !test->countTestCases() )
            {
                std::cerr << argv[argc] << ": does not match any test or group" << std::endl;
                return 1;
            }
            test_list.push_back( test );
        }
    }
    // Otherwise do Unit and Regression suites
    else
    {
        test = CppUnit::TestFactoryRegistry::getRegistry( "Unit" ).makeTest();
        test_list.push_back( test );
        test = CppUnit::TestFactoryRegistry::getRegistry( "Regression" ).makeTest();
        test_list.push_back( test );
    }

    // If user just wants list of tests
    if( list )
    {
        for( vector< CppUnit::Test* >::iterator i = test_list.begin(); i != test_list.end(); ++i )
        {
            CppUnit::TestSuite* suite = dynamic_cast< CppUnit::TestSuite* >( *i );
            if( !suite )
            {
                cout << ( *i )->getName() << endl;
                continue;
            }
            const vector< CppUnit::Test* >& list = suite->getTests();
            for( vector< CppUnit::Test* >::const_iterator j = list.begin(); j != list.end(); ++j )
                cout << ( *j )->getName() << endl;
        }
    }
    // Otherwise run the tests
    else
    {
        for( vector< CppUnit::Test* >::iterator i = test_list.begin(); i != test_list.end(); ++i )
            runner.addTest( *i );
        return !runner.run();
    }

    // Return 0 if there were no errors
    return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines