Ticket #2488: cxxtest-fix.patch

File cxxtest-fix.patch, 32.2 KB (added by leper, 10 years ago)

wip patch, parts of it will be submitted upstream

  • libraries/source/cxxtest-4.3/cxxtest/Gui.h

     
    2727    GuiListener() : _state(GREEN_BAR) {}
    2828    virtual ~GuiListener() {}
    2929
    30     virtual void runGui(int &argc, char **argv, TestListener &listener)
     30    virtual void runGui(TestListener &listener)
    3131    {
    32         enterGui(argc, argv);
     32        enterGui();
    3333        TestRunner::runAllTests(listener);
    3434        leaveGui();
    3535    }
    3636
    37     virtual void enterGui(int & /*argc*/, char ** /*argv*/) {}
     37    virtual void enterGui() {}
    3838    virtual void leaveGui() {}
    3939
    4040    //
     
    171171template<class GuiT, class TuiT>
    172172class GuiTuiRunner : public TeeListener
    173173{
    174     int* _argc;
    175     char **_argv;
    176174    GuiT _gui;
    177175    TuiT _tui;
    178176
    179177public:
    180     GuiTuiRunner() : _argc(0), _argv(0) {}
     178    GuiTuiRunner() {}
    181179
    182     void process_commandline(int& argc, char** argv)
     180    bool process_commandline_args(int& i, int& argc, char* argv[])
    183181    {
    184         _argc = &argc;
    185         _argv = argv;
    186         setFirst(_gui);
    187         setSecond(_tui);
     182        if (i == 0) // Init
     183        {
     184            setFirst(_gui);
     185            setSecond(_tui);
     186        }
     187        return _gui.parse_commandline_args(i, argc, argv);
     188    }
     189
     190    void print_help(const char* name)
     191    {
     192        _gui.print_help(name);
    188193    }
    189194
    190195    int run()
    191196    {
    192         _gui.runGui(*_argc, _argv, *this);
     197        _gui.runGui(*this);
    193198        return tracker().failedTests();
    194199    }
    195200};
  • libraries/source/cxxtest-4.3/cxxtest/PsTestWrapper.cpp

     
    11#include <cxxtest/PsTestWrapper.h>
    22
    3 namespace CxxTest 
     3namespace CxxTest
    44{
    5     const char *g_PsArgv0 = NULL;
    6     const char *g_PsOnlySuite = NULL;
    7     const char *g_PsOnlyTest = NULL;
    8     bool g_PsListSuites = false;
    9 }
    10  No newline at end of file
     5const char *g_PsOnlySuite = NULL;
     6const char *g_PsOnlyTest = NULL;
     7}
  • libraries/source/cxxtest-4.3/cxxtest/PsTestWrapper.h

     
    11#ifndef __cxxtest__PsTestWrapper_h__
    22#define __cxxtest__PsTestWrapper_h__
    33
    4 #include <cstdio>
    5 
     4#include <cxxtest/TestMain.h>
    65#include <cxxtest/Gui.h>
    76// (This is not actually a GUI, but we use the CxxTest GUI mechanism
    87// to capture argv and do some special processing)
     
    1817
    1918#include "ps/DllLoader.h"
    2019
    21 namespace CxxTest 
     20namespace CxxTest
    2221{
    23     extern const char *g_PsArgv0;
    24     extern const char *g_PsOnlySuite;
    25     extern const char *g_PsOnlyTest;
    26     extern bool g_PsListSuites;
     22extern const char *g_PsOnlySuite;
     23extern const char *g_PsOnlyTest;
    2724
    28     class PsTestRunner : public TestRunner
     25class PsTestRunner : public TestRunner
     26{
     27public:
     28    static void runAllTests(TestListener &listener)
    2929    {
    30     public:
    31         static void runAllTests( TestListener &listener )
    32         {
    33             // Code copied from TestRunner:
    34             tracker().setListener( &listener );
    35             _TS_TRY { PsTestRunner().runWorld(); }
    36             _TS_LAST_CATCH( { tracker().failedTest( __FILE__, __LINE__, "Exception thrown from world" ); } );
    37             tracker().setListener( 0 );
    38         }
    39 
    40         void runWorld()
    41         {
    42             RealWorldDescription wd;
    43             WorldGuard sg;
     30        // Code copied from TestRunner:
     31        tracker().setListener(&listener);
     32        _TS_TRY { PsTestRunner().runWorld(); }
     33        _TS_LAST_CATCH({ tracker().failedTest(__FILE__, __LINE__, "Exception thrown from world"); });
     34        tracker().setListener(0);
     35    }
    4436
    45             // Print all the (initially active) test suites, as an
    46             // occasionally handy test-runner-debugging feature
    47             if ( g_PsListSuites )
    48                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() )
    49                     if ( sd->active() )
    50                         printf( "%s\n", sd->suiteName() );
     37    void runWorld()
     38    {
     39        RealWorldDescription wd;
     40        WorldGuard sg;
    5141
    52             // Allow all but one suite/test to be disabled
    53             if ( g_PsOnlySuite ) {
    54                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) {
    55                     if ( stringsEqual( sd->suiteName(), g_PsOnlySuite ) ) {
    56                         for ( TestDescription *td = sd->firstTest(); td; td = td->next() )
    57                             if ( g_PsOnlyTest && !stringsEqual( td->testName(), g_PsOnlyTest ) )
    58                                 td->setActive( false );
    59                     } else {
    60                         sd->setActive( false );
    61                     }
    62                 }
    63             }
    64             else
     42        // Allow all but one suite/test to be disabled
     43        if (g_PsOnlySuite)
     44        {
     45            for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next())
    6546            {
    66                 // By default, disable all tests with names containing "DISABLED"
    67                 // (they can only be run by explicitly naming the suite/test)
    68                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) {
    69                     for ( TestDescription *td = sd->firstTest(); td; td = td->next() )
    70                         if ( strstr( td->testName(), "DISABLED" ) )
    71                             td->setActive( false );
     47                if (stringsEqual(sd->suiteName(), g_PsOnlySuite))
     48                {
     49                    for (TestDescription *td = sd->firstTest(); td; td = td->next())
     50                        if (g_PsOnlyTest && !stringsEqual(td->testName(), g_PsOnlyTest))
     51                        {
     52                            td->setActive(false);
     53                        }
     54                }
     55                else
     56                {
     57                    sd->setActive(false);
    7258                }
    7359            }
    74 
    75             // Code copied from TestRunner:
    76             tracker().enterWorld( wd );
    77             if ( wd.setUp() ) {
    78                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() )
    79                     if ( sd->active() ) {
    80                         runSuite( *sd );
     60        }
     61        else
     62        {
     63            // By default, disable all tests with names containing "DISABLED"
     64            // (they can only be run by explicitly naming the suite/test)
     65            for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next())
     66            {
     67                for (TestDescription *td = sd->firstTest(); td; td = td->next())
     68                    if (strstr(td->testName(), "DISABLED"))
     69                    {
     70                        td->setActive(false);
    8171                    }
    82                 wd.tearDown();
    8372            }
    84             tracker().leaveWorld( wd );
    8573        }
    86     };
    8774
    88     class PsTestWrapper : public PS_TEST_WRAPPER_BASE
     75        // Code copied from TestRunner:
     76        tracker().enterWorld(wd);
     77        if (wd.setUp())
     78        {
     79            for (SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next())
     80                if (sd->active())
     81                {
     82                    runSuite(*sd);
     83                }
     84            wd.tearDown();
     85        }
     86        tracker().leaveWorld(wd);
     87    }
     88};
     89
     90class PsTestWrapper : public PS_TEST_WRAPPER_BASE
     91{
     92public:
     93    virtual void runGui(TestListener &listener)
     94    {
     95        enterGui();
     96        PsTestRunner::runAllTests(listener);
     97        leaveGui();
     98    }
     99    virtual bool parse_commandline_args(int& i, int& argc, char* argv[])
    89100    {
    90     public:
    91         virtual void runGui( int &argc, char **argv, TestListener &listener )
     101        if (i == 0)
    92102        {
    93             parseCommandLine( argc, argv );
    94             enterGui( argc, argv );
    95             PsTestRunner::runAllTests( listener );
    96             leaveGui();
     103            return true;
    97104        }
    98     private:
    99         void parseCommandLine( int argc, char **argv )
     105
     106        if (!strcmp(argv[i], "-libdir"))
    100107        {
    101             g_PsArgv0 = argv[0];
     108            if (++i >= argc) // TODO warn about missing arg
     109            {
     110                return false;
     111            }
    102112
    103             for ( int i = 1; i < argc; ++i ) {
    104                 if ( !strcmp( argv[i], "-test" ) && (i + 1 < argc) ) {
    105                     char *test = argv[++i];
    106                     // Try splitting as "suite::test", else use the whole string as the suite name
    107                     char *colons = strstr( test, "::" );
    108                     if ( colons ) {
    109                         colons[0] = '\0'; // (modifying argv is safe enough)
    110                         g_PsOnlySuite = test;
    111                         g_PsOnlyTest = colons + 2;
    112                     } else {
    113                         g_PsOnlySuite = test;
    114                     }
    115                 } else if ( !strcmp( argv[i], "-list" ) ) {
    116                     g_PsListSuites = true;
    117                 } else if ( !strcmp( argv[i], "-libdir" ) ) {
    118                     DllLoader::OverrideLibdir( argv[++i] );
    119                 } else {
    120                     fprintf( stderr, "Unrecognized command line option '%s'\n", argv[i] );
    121                     fprintf( stderr, "Permitted options:\n" );
    122                     fprintf( stderr, "  %s -list\n", argv[0] );
    123                     fprintf( stderr, "  %s -test TestSuiteName\n", argv[0] );
    124                     fprintf( stderr, "  %s -test TestSuiteName::test_case_name\n", argv[0] );
    125                     fprintf( stderr, "  %s -libdir .\n", argv[0] );
    126                     fprintf( stderr, "\n" );
    127                 }
     113            DllLoader::OverrideLibdir(argv[i]);
     114        }
     115        else if (!strcmp(argv[i], "-test")) // Superseded by just specifying the "Suite" or "Suite Test" on the cli
     116        {
     117            if (++i >= argc)
     118            {
     119                return false;
     120            }
     121
     122            char *test = argv[i];
     123            // Try splitting as "suite::test", else use the whole string as the suite name
     124            char *colons = strstr(test, "::");
     125            if (colons)
     126            {
     127                colons[0] = '\0'; // (modifying argv is safe enough)
     128                g_PsOnlySuite = test;
     129                g_PsOnlyTest = colons + 2;
     130            }
     131            else
     132            {
     133                g_PsOnlySuite = test;
    128134            }
    129135        }
    130     };
     136        else
     137        {
     138            return false;
     139        }
     140
     141        return true;
     142    }
     143    virtual void print_help(const char* name)
     144    {
     145        CXXTEST_STD(cerr) << name << " -test TestSuiteName\n";
     146        CXXTEST_STD(cerr) << name << " -test TestSuiteName::test_case_name\n";
     147        CXXTEST_STD(cerr) << name << " -libdir <dir>" << CXXTEST_STD(endl);
     148    }
     149private:
     150    /*void parseCommandLine( int argc, char **argv )
     151    {
     152            if ( !strcmp( argv[i], "-test" ) && (i + 1 < argc) ) {
     153                        } else if ( !strcmp( argv[i], "-list" ) ) { // duplicates --help-tests
     154                g_PsListSuites = true;
     155            } else {
     156                fprintf( stderr, "  %s -list\n", argv[0] );
     157    }*/
     158};
    131159}
    132160
    133 #endif // __cxxtest__PsTestWrapper_h__
    134  No newline at end of file
     161#endif // __cxxtest__PsTestWrapper_h__
  • libraries/source/cxxtest-4.3/cxxtest/QtGui.h

     
    4141class QtGui : public GuiListener
    4242{
    4343public:
    44     void enterGui(int &argc, char **argv)
    45     {
    46         parseCommandLine(argc, argv);
    47         createApplication(argc, argv);
    48     }
    49 
    5044    void enterWorld(const WorldDescription &wd)
    5145    {
    5246        createWindow(wd);
     
    10094        }
    10195    }
    10296
     97    virtual bool parse_commandline_args(int& i, int& argc, char* argv[])
     98    {
     99        if (i == 0)
     100        {
     101            _startMinimized = _keep = false;
     102            _title = argv[0];
     103            // Removes arguments it recognizes
     104            _application = new QApplication(argc, argv);
     105            return true;
     106        }
     107
     108        if (!strcmp(argv[i], "-minimized"))
     109        {
     110            _startMinimized = true;
     111        }
     112        else if (!strcmp(argv[i], "-keep"))
     113        {
     114            _keep = true;
     115        }
     116        else if (!strcmp(argv[i], "-title"))
     117        {
     118            if (++i >= argc)
     119            {
     120                return false;
     121            }
     122
     123            _title = argv[i];
     124        }
     125        else
     126        {
     127            return false;
     128        }
     129
     130        return true;
     131    }
     132
    103133private:
    104134    QString _title;
    105135    bool _startMinimized, _keep;
     
    112142    QStatusBar *_statusBar;
    113143    QLabel *_suiteName, *_testName, *_testsDone;
    114144
    115     void parseCommandLine(int argc, char **argv)
    116     {
    117         _startMinimized = _keep = false;
    118         _title = argv[0];
    119 
    120         for (int i = 1; i < argc; ++ i)
    121         {
    122             QString arg(argv[i]);
    123             if (arg == "-minimized")
    124             {
    125                 _startMinimized = true;
    126             }
    127             else if (arg == "-keep")
    128             {
    129                 _keep = true;
    130             }
    131             else if (arg == "-title" && (i + 1 < argc))
    132             {
    133                 _title = argv[++i];
    134             }
    135         }
    136     }
    137 
    138     void createApplication(int &argc, char **argv)
    139     {
    140         _application = new QApplication(argc, argv);
    141     }
    142 
    143145    void createWindow(const WorldDescription &wd)
    144146    {
    145147        getTotalTests(wd);
  • libraries/source/cxxtest-4.3/cxxtest/RealDescriptions.cpp

     
    5555    {
    5656        bool ok;
    5757        _TS_TRY { ok = gf->setUp(); }
    58         _TS_LAST_CATCH( { ok = false; });
     58        _TS_LAST_CATCH({ ok = false; });
    5959
    6060        if (!ok)
    6161        {
     
    7070        _TSM_ASSERT_THROWS_NOTHING(file(), line(), "Exception thrown from setUp()", suite()->setUp(); ok = true);
    7171        if (ok == false) { return ok; }
    7272    }
    73     _TS_CATCH_ABORT( { return false; })
    74     _TS_CATCH_SKIPPED( { return false; });
     73    _TS_CATCH_ABORT({ return false; })
     74    _TS_CATCH_SKIPPED({ return false; });
    7575
    7676    return true;
    7777}
     
    8787    {
    8888        _TSM_ASSERT_THROWS_NOTHING(file(), line(), "Exception thrown from tearDown()", suite()->tearDown());
    8989    }
    90     _TS_CATCH_ABORT( { return false; })
    91     _TS_CATCH_SKIPPED( { return false; });
     90    _TS_CATCH_ABORT({ return false; })
     91    _TS_CATCH_SKIPPED({ return false; });
    9292
    9393    for (GlobalFixture *gf = GlobalFixture::lastGlobalFixture(); gf != 0; gf = gf->prevGlobalFixture())
    9494    {
    9595        bool ok;
    9696        _TS_TRY { ok = gf->tearDown(); }
    97         _TS_LAST_CATCH( { ok = false; });
     97        _TS_LAST_CATCH({ ok = false; });
    9898
    9999        if (!ok)
    100100        {
     
    119119void RealTestDescription::run()
    120120{
    121121    _TS_TRY { runTest(); }
    122     _TS_CATCH_ABORT( {})
    123     _TS_CATCH_SKIPPED( {})
     122    _TS_CATCH_ABORT({})
     123    _TS_CATCH_SKIPPED({})
    124124    ___TSM_CATCH(file(), line(), "Exception thrown from test");
    125125}
    126126
     
    311311                ok = false;
    312312            }
    313313        }
    314         _TS_LAST_CATCH( { ok = false; });
     314        _TS_LAST_CATCH({ ok = false; });
    315315
    316316        if (!ok)
    317317        {
     
    329329    {
    330330        bool ok;
    331331        _TS_TRY { ok = gf->tearDownWorld(); }
    332         _TS_LAST_CATCH( { ok = false; });
     332        _TS_LAST_CATCH({ ok = false; });
    333333
    334334        if (!ok)
    335335        {
  • libraries/source/cxxtest-4.3/cxxtest/RealDescriptions.h

     
    191191        _TSM_ASSERT_THROWS_NOTHING(file(), _createLine, "Exception thrown from createSuite()", createSuite());
    192192        _TSM_ASSERT(file(), _createLine, "createSuite() failed", suite() != 0);
    193193    }
    194     _TS_CATCH_ABORT( { return false; })
    195     _TS_CATCH_SKIPPED( { return false; });
     194    _TS_CATCH_ABORT({ return false; })
     195    _TS_CATCH_SKIPPED({ return false; });
    196196
    197197    return (suite() != 0);
    198198}
     
    209209    {
    210210        _TSM_ASSERT_THROWS_NOTHING(file(), _destroyLine, "destroySuite() failed", destroySuite());
    211211    }
    212     _TS_CATCH_ABORT( { return false; })
    213     _TS_CATCH_SKIPPED( { return false; });
     212    _TS_CATCH_ABORT({ return false; })
     213    _TS_CATCH_SKIPPED({ return false; });
    214214
    215215    return true;
    216216}
  • libraries/source/cxxtest-4.3/cxxtest/TestListener.h

     
    2323
    2424#include <cxxtest/Descriptions.h>
    2525
     26#include <cstdio>
    2627namespace CxxTest
    2728{
    2829class TestListener
     
    3031public:
    3132    TestListener() {}
    3233    virtual ~TestListener() {}
    33     virtual void process_commandline(int& /*argc*/, char** /*argv*/) {}
     34    virtual void print_help(const char* /*name*/) {}
     35    virtual bool process_commandline_args(int& /*i*/, int& /*argc*/, char* /*argv*/[]) { return false; }
    3436
    3537    virtual void enterWorld(const WorldDescription & /*desc*/) {}
    3638    virtual void enterSuite(const SuiteDescription & /*desc*/) {}
  • libraries/source/cxxtest-4.3/cxxtest/TestMain.h

     
    3333namespace CxxTest
    3434{
    3535
    36 inline void print_help(const char* name)
     36template <class TesterT>
     37inline void print_help(TesterT& tmp, const char* name)
    3738{
    38     CXXTEST_STD(cerr) << name << " <suitename>" << CXXTEST_STD(endl);
    39     CXXTEST_STD(cerr) << name << " <suitename> <testname>" << CXXTEST_STD(endl);
    40     CXXTEST_STD(cerr) << name << " -h" << CXXTEST_STD(endl);
    41     CXXTEST_STD(cerr) << name << " --help" << CXXTEST_STD(endl);
    42     CXXTEST_STD(cerr) << name << " --help-tests" << CXXTEST_STD(endl);
    43     CXXTEST_STD(cerr) << name << " -v             Enable tracing output." << CXXTEST_STD(endl);
     39    CXXTEST_STD(cerr) << name << " <suitename>\n";
     40    CXXTEST_STD(cerr) << name << " <suitename> <testname>\n";
     41    CXXTEST_STD(cerr) << name << " -h\n";
     42    CXXTEST_STD(cerr) << name << " --help\n";
     43    CXXTEST_STD(cerr) << name << " --help-tests\n";
     44    CXXTEST_STD(cerr) << name << " -v             Enable tracing output.\n";
     45    CXXTEST_STD(cerr) << "Frontend specific options:" << CXXTEST_STD(endl);
     46    tmp.print_help(name);
    4447}
    4548#endif
    4649
     
    5457// This is a primitive parser, but I'm not sure what sort of portable
    5558// parser should be used in cxxtest.
    5659//
    57 
    5860#if defined(_CXXTEST_HAVE_STD)
    59 //
    60 // Print command-line syntax
    61 //
    62     for (int i = 1; i < argc; i++)
     61    bool suiteSpecifed = false;
     62    int i = 0;
     63    tmp.process_commandline_args(i, argc, argv);
     64    for (i = 1; i < argc; i++)
    6365    {
    6466        if ((CXXTEST_STD(strcmp)(argv[i], "-h") == 0) || (CXXTEST_STD(strcmp)(argv[i], "--help") == 0))
    6567        {
    66             print_help(argv[0]);
     68            print_help(tmp, argv[0]);
    6769            return 0;
    6870        }
    69         else if ((CXXTEST_STD(strcmp)(argv[1], "--help-tests") == 0))
     71        else if ((CXXTEST_STD(strcmp)(argv[i], "--help-tests") == 0))
    7072        {
    7173            CXXTEST_STD(cout) << "Suite/Test Names" << CXXTEST_STD(endl);
    7274            CXXTEST_STD(cout) << "---------------------------------------------------------------------------" << CXXTEST_STD(endl);
     
    7779                }
    7880            return 0;
    7981        }
    80     }
    81 
    82 //
    83 // Process command-line options here.
    84 //
    85     while ((argc > 1) && (argv[1][0] == '-'))
    86     {
    87         if (CXXTEST_STD(strcmp)(argv[1], "-v") == 0)
     82        else if (CXXTEST_STD(strcmp)(argv[i], "-v") == 0)
    8883        {
    8984            tracker().print_tracing = true;
    9085        }
    91         else
    92         {
    93             CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[1] << "'" << CXXTEST_STD(endl);
    94             return -1;
    95         }
    96         for (int i = 1; i < (argc - 1); i++)
    97         {
    98             argv[i] = argv[i + 1];
    99         }
    100         argc--;
    101     }
    102 
    103 //
    104 // Run experiments
    105 //
    106     bool status = false;
    107     if ((argc == 2) && (argv[1][0] != '-'))
    108     {
    109         status = leaveOnly(argv[1]);
    110         if (!status)
     86        else if (argv[i][0] == '-')
    11187        {
    112             CXXTEST_STD(cerr) << "ERROR: unknown suite '" << argv[1] << "'" << CXXTEST_STD(endl);
    113             return -1;
     88            // Increments i if it handles more arguments
     89            if (!tmp.process_commandline_args(i, argc, argv))
     90            {
     91                CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[i] << "'" << CXXTEST_STD(endl);
     92                return -1;
     93            }
    11494        }
    115     }
    116     if ((argc == 3) && (argv[1][0] != '-'))
    117     {
    118         status = leaveOnly(argv[1], argv[2]);
    119         if (!status)
     95        else
    12096        {
    121             CXXTEST_STD(cerr) << "ERROR: unknown test '" << argv[1] << "::" << argv[2] << "'" << CXXTEST_STD(endl);
    122             return -1;
     97            if (suiteSpecifed)
     98            {
     99                CXXTEST_STD(cerr) << "ERROR: only one suite or one test can be specified" << CXXTEST_STD(endl);
     100                return -1;
     101            }
     102            suiteSpecified = true;
     103            bool status = false;
     104            // Test case and test suite
     105            if (i + 1 < argc) // suite and test
     106            {
     107                status = leaveOnly(argv[i], argv[i + 1]);
     108                if (!status)
     109                {
     110                    CXXTEST_STD(cerr) << "ERROR: unknown test '" << argv[i] << "::" << argv[i + 1] << "'" << CXXTEST_STD(endl);
     111                    return -1;
     112                }
     113                i++; // We handled two parameters
     114            }
     115            else // suite
     116            {
     117                // TODO also handle "Suite::Test"?
     118                status = leaveOnly(argv[i]);
     119                if (!status)
     120                {
     121                    CXXTEST_STD(cerr) << "ERROR: unknown suite '" << argv[i] << "'" << CXXTEST_STD(endl);
     122                    return -1;
     123                }
     124            }
    123125        }
    124126    }
    125127#endif
    126128
    127     tmp.process_commandline(argc, argv);
    128129    return tmp.run();
    129130}
    130131
  • libraries/source/cxxtest-4.3/cxxtest/TestRunner.h

     
    2727{
    2828class TestRunner
    2929{
    30     friend class PsTestRunner;
     30    friend class PsTestRunner;
    3131
    3232public:
    3333
     
    4040    {
    4141        tracker().setListener(&listener);
    4242        _TS_TRY { TestRunner().runWorld(); }
    43         _TS_LAST_CATCH( { tracker().failedTest(__FILE__, __LINE__, "Exception thrown from world"); });
     43        _TS_LAST_CATCH({ tracker().failedTest(__FILE__, __LINE__, "Exception thrown from world"); });
    4444        tracker().setListener(0);
    4545    }
    4646
  • libraries/source/cxxtest-4.3/cxxtest/Win32Gui.h

     
    3838class Win32Gui : public GuiListener
    3939{
    4040public:
    41     void enterGui(int &argc, char **argv)
    42     {
    43         parseCommandLine(argc, argv);
    44     }
    45 
    4641    void enterWorld(const WorldDescription &wd)
    4742    {
    4843        getTotalTests(wd);
     
    9489        DestroyWindow(_mainWindow);
    9590    }
    9691
     92    virtual bool parse_commandline_args(int& i, int& argc, char* argv[])
     93    {
     94        if (i == 0)
     95        {
     96            _startMinimized = _keep = false;
     97            _title = argv[0];
     98            return true;
     99        }
     100
     101        if (!lstrcmpA(argv[i], "-minimized"))
     102        {
     103            _startMinimized = true;
     104        }
     105        else if (!lstrcmpA(argv[i], "-keep"))
     106        {
     107            _keep = false;
     108        }
     109        else if (!lstrcmpA(argv[i], "-title"))
     110        {
     111            if (++i >= argc)
     112            {
     113                return false;
     114            }
     115
     116            _title = argv[i];
     117        }
     118        else
     119        {
     120            return false;
     121        }
     122
     123        return true;
     124    }
     125
    97126private:
    98127    const char *_title;
    99128    bool _startMinimized, _keep;
     
    117146    DWORD _worldStart, _suiteStart, _testStart;
    118147    char _timeString[sizeof("00:00:00")];
    119148
    120     void parseCommandLine(int argc, char **argv)
    121     {
    122         _startMinimized = _keep = false;
    123         _title = argv[0];
    124 
    125         for (int i = 1; i < argc; ++ i)
    126         {
    127             if (!lstrcmpA(argv[i], "-minimized"))
    128             {
    129                 _startMinimized = true;
    130             }
    131             else if (!lstrcmpA(argv[i], "-keep"))
    132             {
    133                 _keep = true;
    134             }
    135             else if (!lstrcmpA(argv[i], "-title") && (i + 1 < argc))
    136             {
    137                 _title = argv[++i];
    138             }
    139         }
    140     }
    141 
    142149    void getTotalTests()
    143150    {
    144151        getTotalTests(tracker().world());
  • libraries/source/cxxtest-4.3/cxxtest/Win32ODSPrinter.h

     
    55
    66#include "lib/sysdep/os/win/win.h"
    77
    8 namespace CxxTest 
     8namespace CxxTest
    99{
    10     class ods_ostreambuf : public std::streambuf
    11     {
    12         std::streamsize xsputn(const char* s, std::streamsize n)
    13         {
    14             char* buf = new char[n+1];
    15             memcpy(buf, s, n);
    16             buf[n] = '\0';
    17             OutputDebugStringA(buf);
    18             delete[] buf;
    19             return n;
    20         }
    21     };
     10class ods_ostreambuf : public std::streambuf
     11{
     12    std::streamsize xsputn(const char* s, std::streamsize n)
     13    {
     14        char* buf = new char[n + 1];
     15        memcpy(buf, s, n);
     16        buf[n] = '\0';
     17        OutputDebugStringA(buf);
     18        delete[] buf;
     19        return n;
     20    }
     21};
    2222
    23     class Win32ODSPrinter : public ParenPrinter
    24     {
    25         ods_ostreambuf buf;
    26         std::ostream ostr;
    27     public:
    28         Win32ODSPrinter() : buf(), ostr(&buf), ParenPrinter(ostr) {}
    29     };
     23class Win32ODSPrinter : public ParenPrinter
     24{
     25    ods_ostreambuf buf;
     26    std::ostream ostr;
     27public:
     28    Win32ODSPrinter() : buf(), ostr(&buf), ParenPrinter(ostr) {}
     29};
    3030}
    3131
    3232#endif // __cxxtest__Win32ODSPrinter_h__
     33 No newline at end of file
  • libraries/source/cxxtest-4.3/cxxtest/X11Gui.h

     
    3636class X11Gui : public GuiListener
    3737{
    3838public:
    39     void enterGui(int &argc, char **argv)
    40     {
    41         parseCommandLine(argc, argv);
    42     }
    43 
    4439    void enterWorld(const WorldDescription &wd)
    4540    {
    4641        openDisplay();
     
    9893        }
    9994    }
    10095
    101 private:
    102     const char *_programName;
    103     Display *_display;
    104     Window _window;
    105     unsigned _numTotalTests, _testsDone;
    106     char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS];
    107     const char *_foregroundName, *_backgroundName;
    108     const char *_greenName, *_yellowName, *_redName;
    109     unsigned long _foreground, _background, _barColor;
    110     int _width, _height;
    111     GC _gc;
    112     const char *_fontName;
    113     XID _fontId;
    114     XFontStruct *_fontInfo;
    115     int _textHeight, _textDescent;
    116     long _eventMask;
    117     Colormap _colormap;
    118 
    119     void parseCommandLine(int &argc, char **argv)
     96    virtual bool parse_commandline_args(int& i, int& argc, char* argv[])
    12097    {
    121         _programName = argv[0];
    122 
    123         _fontName = 0;
    124         _foregroundName = "Black";
    125         _backgroundName = "Grey";
    126         _greenName = "Green";
    127         _yellowName = "Yellow";
    128         _redName = "Red";
     98        if (i == 0)
     99        {
     100            _programName = argv[0];
     101
     102            _fontName = 0;
     103            _foregroundName = "Black";
     104            _backgroundName = "Grey";
     105            _greenName = "Green";
     106            _yellowName = "Yellow";
     107            _redName = "Red";
     108            return true;
     109        }
    129110
    130         for (int i = 1; i + 1 < argc; ++ i)
     111        if (!strcmp(argv[i], "-title"))
    131112        {
    132             if (!strcmp(argv[i], "-title"))
     113            if (++i >= argc)
    133114            {
    134                 _programName = argv[++ i];
     115                return false;
    135116            }
    136             else if (!strcmp(argv[i], "-fn") || !strcmp(argv[i], "-font"))
     117
     118            _programName = argv[i];
     119            return true;
     120        }
     121        else if (!strcmp(argv[i], "-fn") || !strcmp(argv[i], "-font"))
     122        {
     123            if (++i >= argc)
    137124            {
    138                 _fontName = argv[++ i];
     125                return false;
    139126            }
    140             else if (!strcmp(argv[i], "-fg") || !strcmp(argv[i], "-foreground"))
     127
     128            _fontName = argv[i];
     129            return true;
     130        }
     131        else if (!strcmp(argv[i], "-fg") || !strcmp(argv[i], "-foreground"))
     132        {
     133            if (++i >= argc)
    141134            {
    142                 _foregroundName = argv[++ i];
     135                return false;
    143136            }
    144             else if (!strcmp(argv[i], "-bg") || !strcmp(argv[i], "-background"))
     137
     138            _foregroundName = argv[i];
     139            return true;
     140        }
     141        else if (!strcmp(argv[i], "-bg") || !strcmp(argv[i], "-background"))
     142        {
     143            if (++i >= argc)
    145144            {
    146                 _backgroundName = argv[++ i];
     145                return false;
    147146            }
    148             else if (!strcmp(argv[i], "-green"))
     147
     148            _backgroundName = argv[i];
     149            return true;
     150        }
     151        else if (!strcmp(argv[i], "-green"))
     152        {
     153            if (++i >= argc)
    149154            {
    150                 _greenName = argv[++ i];
     155                return false;
    151156            }
    152             else if (!strcmp(argv[i], "-yellow"))
     157
     158            _greenName = argv[i];
     159            return true;
     160        }
     161        else if (!strcmp(argv[i], "-yellow"))
     162        {
     163            if (++i >= argc)
    153164            {
    154                 _yellowName = argv[++ i];
     165                return false;
    155166            }
    156             else if (!strcmp(argv[i], "-red"))
     167
     168            _yellowName = argv[i];
     169            return true;
     170        }
     171        else if (!strcmp(argv[i], "-red"))
     172        {
     173            if (++i >= argc)
    157174            {
    158                 _redName = argv[++ i];
     175                return false;
    159176            }
     177
     178            _redName = argv[i];
     179            return true;
    160180        }
     181        return false;
    161182    }
    162183
     184private:
     185    const char *_programName;
     186    Display *_display;
     187    Window _window;
     188    unsigned _numTotalTests, _testsDone;
     189    char _strTotalTests[WorldDescription::MAX_STRLEN_TOTAL_TESTS];
     190    const char *_foregroundName, *_backgroundName;
     191    const char *_greenName, *_yellowName, *_redName;
     192    unsigned long _foreground, _background, _barColor;
     193    int _width, _height;
     194    GC _gc;
     195    const char *_fontName;
     196    XID _fontId;
     197    XFontStruct *_fontInfo;
     198    int _textHeight, _textDescent;
     199    long _eventMask;
     200    Colormap _colormap;
     201
    163202    void openDisplay()
    164203    {
    165204        _display = XOpenDisplay(NULL);
  • libraries/source/cxxtest-4.3/cxxtest/XmlFormatter.h

     
    385385        std::ostringstream os;
    386386        const time_t current_date(time(0));
    387387        char current_date_string[27];
    388         const size_t n = strlen(ctime_r(&current_date,current_date_string));
    389         if (n) {
    390             current_date_string[n-1] = '\0'; // remove the ending \n
    391         } else {
     388        const size_t n = strlen(ctime_r(&current_date, current_date_string));
     389        if (n)
     390        {
     391            current_date_string[n - 1] = '\0'; // remove the ending \n
     392        }
     393        else
     394        {
    392395            current_date_string[0] = '\0'; // just in case...
    393396        }
    394397        os << totaltime;