Revision 496, 1.0 kB
(checked in by vbarta, 15 years ago)
|
testsuite now allows running individual tests: when run with command-line arguments, they're interpreted as test names and only those tests are run
|
Line | |
---|
1 | #include "Test.h" |
---|
2 | #include "TestReporterStdout.h" |
---|
3 | #include "UnitTest++.h" |
---|
4 | #include "itpp_ext.h" |
---|
5 | |
---|
6 | using namespace itpp; |
---|
7 | |
---|
8 | Array<const char *> selected_tests; |
---|
9 | |
---|
10 | bool is_selected_test( const UnitTest::Test *test ) { |
---|
11 | it_assert_debug ( test, "NULL test" ); |
---|
12 | |
---|
13 | if (!selected_tests.length()) { |
---|
14 | return true; |
---|
15 | } |
---|
16 | |
---|
17 | for (int i = 0; i < selected_tests.length(); ++i) { |
---|
18 | const char *n = test->m_details.testName; |
---|
19 | it_assert_debug ( n, "NULL test name" ); |
---|
20 | const char *sname = selected_tests(i); |
---|
21 | it_assert_debug ( sname, "NULL selected test name" ); |
---|
22 | if ( !strcmp ( n, sname ) ) { |
---|
23 | return true; |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | return false; |
---|
28 | } |
---|
29 | |
---|
30 | int main ( int argc, char const *argv[] ) { |
---|
31 | if ( argc > 1 ) { |
---|
32 | selected_tests.set_length( argc - 1 ); |
---|
33 | const char **param = argv + 1; |
---|
34 | int i = 0; |
---|
35 | while ( *param ) { |
---|
36 | selected_tests ( i ) = *param; |
---|
37 | ++i; |
---|
38 | ++param; |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | itpp::RNG_randomize(); |
---|
43 | |
---|
44 | UnitTest::TestReporterStdout reporter; |
---|
45 | UnitTest::TestRunner runner ( reporter ); |
---|
46 | return runner.RunTestsIf ( UnitTest::Test::GetTestList(), |
---|
47 | 0, |
---|
48 | is_selected_test, |
---|
49 | 0 ); |
---|
50 | } |
---|