Show
Ignore:
Timestamp:
11/02/09 01:09:42 (15 years ago)
Author:
mido
Message:

new version of libconfig added
an improvement of testsuite - calling of "testsuite print" prints all the currently prepared unit tests
a CMakeLists.txt modificiation to remowe CMake 2.8 warnings

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/testsuite.cpp

    r565 r689  
    66#include <string.h> 
    77 
     8using std::cout; 
     9using std::cerr; 
     10using std::endl; 
     11 
    812using namespace itpp; 
    913 
    1014Array<const char *> selected_tests; 
    1115 
    12 bool is_selected_test( const UnitTest::Test *test ) { 
     16bool is_selected_test ( const UnitTest::Test *test ) { 
    1317        bdm_assert_debug ( test, "NULL test" ); 
    1418 
    15         if (!selected_tests.length()) { 
     19        if ( !selected_tests.length() ) { 
    1620                return true; 
    1721        } 
    1822 
    19         for (int i = 0; i < selected_tests.length(); ++i) { 
     23        for ( int i = 0; i < selected_tests.length(); ++i ) { 
    2024                const char *n = test->m_details.testName; 
    2125                bdm_assert_debug ( n, "NULL test name" ); 
    22                 const char *sname = selected_tests(i); 
     26                const char *sname = selected_tests ( i ); 
    2327                bdm_assert_debug ( sname, "NULL selected test name" ); 
    2428                if ( !strcmp ( n, sname ) ) { 
     
    3236int main ( int argc, char const *argv[] ) { 
    3337        if ( argc > 1 ) { 
    34                 selected_tests.set_length( argc - 1 ); 
    35                 const char **param = argv + 1; 
    36                 int i = 0; 
    37                 while ( *param ) { 
    38                         selected_tests ( i ) = *param; 
    39                         ++i; 
    40                         ++param; 
     38                if ( !strcmp ( argv[1], "print" ) ) { 
     39                        UnitTest::Test* curTest = UnitTest::Test::GetTestList().GetHead(); 
     40 
     41                        while ( curTest != 0 ) { 
     42                                const char *n = curTest->m_details.testName; 
     43                                printf ( "%s\n", n ); 
     44                                curTest = curTest->next; 
     45                        } 
     46                        return 0; 
     47                } else { 
     48                        selected_tests.set_length ( argc - 1 ); 
     49                        const char **param = argv + 1; 
     50                        int i = 0; 
     51                        while ( *param ) { 
     52                                selected_tests ( i ) = *param; 
     53                                ++i; 
     54                                ++param; 
     55                        } 
    4156                } 
     57        } else { 
     58                cout << "usage: " << endl << 
     59                     "\"" << argv[0] << "\" - to run all unit tests " << endl << 
     60                     "\"" << argv[0] << " particular_test_1 particular_test_2\" - to run selected unit tests" << endl << 
     61                     "\"" << argv[0] << " print\" - to print all the implemented unit tests" << endl; 
    4262        } 
    4363 
     
    4767        UnitTest::TestRunner runner ( reporter ); 
    4868        return runner.RunTestsIf ( UnitTest::Test::GetTestList(), 
    49                                    0, 
    50                                    is_selected_test, 
    51                                    0 ); 
     69                                   0, 
     70                                   is_selected_test, 
     71                                   0 ); 
    5272}