[496] | 1 | #include "Test.h" |
---|
| 2 | #include "TestReporterStdout.h" |
---|
[418] | 3 | #include "UnitTest++.h" |
---|
[565] | 4 | #include "bdmerror.h" |
---|
[452] | 5 | #include "itpp_ext.h" |
---|
[565] | 6 | #include <string.h> |
---|
[418] | 7 | |
---|
[689] | 8 | using std::cout; |
---|
| 9 | using std::cerr; |
---|
| 10 | using std::endl; |
---|
| 11 | |
---|
[496] | 12 | using namespace itpp; |
---|
| 13 | |
---|
| 14 | Array<const char *> selected_tests; |
---|
| 15 | |
---|
[689] | 16 | bool is_selected_test ( const UnitTest::Test *test ) { |
---|
[565] | 17 | bdm_assert_debug ( test, "NULL test" ); |
---|
[496] | 18 | |
---|
[689] | 19 | if ( !selected_tests.length() ) { |
---|
[496] | 20 | return true; |
---|
| 21 | } |
---|
| 22 | |
---|
[689] | 23 | for ( int i = 0; i < selected_tests.length(); ++i ) { |
---|
[496] | 24 | const char *n = test->m_details.testName; |
---|
[565] | 25 | bdm_assert_debug ( n, "NULL test name" ); |
---|
[689] | 26 | const char *sname = selected_tests ( i ); |
---|
[565] | 27 | bdm_assert_debug ( sname, "NULL selected test name" ); |
---|
[496] | 28 | if ( !strcmp ( n, sname ) ) { |
---|
| 29 | return true; |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | return false; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | int main ( int argc, char const *argv[] ) { |
---|
| 37 | if ( argc > 1 ) { |
---|
[689] | 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 | } |
---|
[496] | 56 | } |
---|
[689] | 57 | } else { |
---|
[721] | 58 | cout << endl << "TESTSUITE - a program covering all BDM unit tests." << endl << endl |
---|
| 59 | << argv[0] << " ....................................... run all unit tests" << endl |
---|
| 60 | << argv[0] << " particular_test_1 particular_test_2 ... run selected unit tests" << endl |
---|
| 61 | << argv[0] << " print ................................. print all the implemented unit tests" << endl; |
---|
[496] | 62 | } |
---|
| 63 | |
---|
[477] | 64 | itpp::RNG_randomize(); |
---|
[496] | 65 | |
---|
| 66 | UnitTest::TestReporterStdout reporter; |
---|
| 67 | UnitTest::TestRunner runner ( reporter ); |
---|
| 68 | return runner.RunTestsIf ( UnitTest::Test::GetTestList(), |
---|
[689] | 69 | 0, |
---|
| 70 | is_selected_test, |
---|
| 71 | 0 ); |
---|
[418] | 72 | } |
---|