aboutsummaryrefslogtreecommitdiff
path: root/test/cxxtest/sample/only.tpl
blob: b2a7277cf637f79d947900db1ee1a9aa60f69fbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// -*- C++ -*-
#include <cxxtest/StdioPrinter.h>
#include <stdio.h>

int main( int argc, char *argv[] )
{
    if ( argc < 2 || argc > 3 ) {
        fprintf( stderr, "Usage: only <suite name> [<test name>]\n\n" );
        fprintf( stderr, "Available tests:\n" );
        CxxTest::RealWorldDescription wd;
        for ( CxxTest::SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() )
            for ( CxxTest::TestDescription *td = sd->firstTest(); td; td = td->next() )
                fprintf( stderr, " - %s::%s()\n", sd->suiteName(), td->testName() );
        return 1;
    }

    const char *suiteName = argv[1];
    const char *testName = (argc > 2) ? argv[2] : 0;
    if ( !CxxTest::leaveOnly( suiteName, testName ) ) {
        if ( testName )
            fprintf( stderr, "Cannot find %s::%s()\n", argv[1], argv[2] );
        else
            fprintf( stderr, "Cannot find class %s\n", argv[1] );
        return 2;
    }
    
    return CxxTest::StdioPrinter().run();
}


// The CxxTest "world"
<CxxTest world>