Commit d0bded42fe8c642f750aa1ed45252dffb7906fb7
1 parent
e2e9409d
Use GammaLib unit classes for test_GApplication.cpp
Showing
1 changed file
with
30 additions
and
34 deletions
test/test_GApplication.cpp
| ... | ... | @@ -39,26 +39,23 @@ |
| 39 | 39 | /*************************************************************************** |
| 40 | 40 | * Test: GLog * |
| 41 | 41 | ***************************************************************************/ |
| 42 | -void test_GLog(void) | |
| 42 | +void test_GLog(GTestSuite& testsuite) | |
| 43 | 43 | { |
| 44 | - // Dump header | |
| 45 | - std::cout << "Test GLog: "; | |
| 46 | - | |
| 47 | 44 | // Test constructor |
| 45 | + testsuite.test_try("Test GLog constructor"); | |
| 48 | 46 | try { |
| 49 | 47 | GLog log1; |
| 50 | 48 | GLog log2 = log1; |
| 49 | + | |
| 50 | + // Test success | |
| 51 | + testsuite.test_try_success(); | |
| 51 | 52 | } |
| 52 | 53 | catch (std::exception &e) { |
| 53 | - std::cout << std::endl | |
| 54 | - << "TEST ERROR: Unable to construct GLog object." | |
| 55 | - << std::endl; | |
| 56 | - std::cout << e.what() << std::endl; | |
| 57 | - throw; | |
| 54 | + testsuite.test_try_failure(e); | |
| 58 | 55 | } |
| 59 | - std::cout << "."; | |
| 60 | 56 | |
| 61 | 57 | // Test stream logger |
| 58 | + testsuite.test_try("Test stream logger"); | |
| 62 | 59 | try { |
| 63 | 60 | GLog log; |
| 64 | 61 | log.date(true); |
| ... | ... | @@ -71,17 +68,15 @@ void test_GLog(void) |
| 71 | 68 | log << "5. This is a character: " << 'a' << std::endl; |
| 72 | 69 | log << "6. This is a C string: " << "a" << std::endl; |
| 73 | 70 | log << "7. This is a Boolean: " << true << std::endl; |
| 71 | + | |
| 72 | + testsuite.test_try_success(); | |
| 74 | 73 | } |
| 75 | 74 | catch (std::exception &e) { |
| 76 | - std::cout << std::endl | |
| 77 | - << "TEST ERROR: Unable to stream into GLog object." | |
| 78 | - << std::endl; | |
| 79 | - std::cout << e.what() << std::endl; | |
| 80 | - throw; | |
| 75 | + testsuite.test_try_failure(e); | |
| 81 | 76 | } |
| 82 | - std::cout << "."; | |
| 83 | 77 | |
| 84 | 78 | // Test C logger |
| 79 | + testsuite.test_try("Test C logger"); | |
| 85 | 80 | try { |
| 86 | 81 | GLog log; |
| 87 | 82 | log.date(true); |
| ... | ... | @@ -91,19 +86,13 @@ void test_GLog(void) |
| 91 | 86 | log("%s %d", "9. This is an integer:", int(1)); |
| 92 | 87 | log("%s %f", "10. This is a single precision:", float(1.23456789)); |
| 93 | 88 | log("%s %f", "11. This is a double precision:", double(1.23456789)); |
| 89 | + | |
| 90 | + testsuite.test_try_success(); | |
| 94 | 91 | } |
| 95 | 92 | catch (std::exception &e) { |
| 96 | - std::cout << std::endl | |
| 97 | - << "TEST ERROR: Unable to write into GLog object." | |
| 98 | - << std::endl; | |
| 99 | - std::cout << e.what() << std::endl; | |
| 100 | - throw; | |
| 93 | + testsuite.test_try_failure(e); | |
| 101 | 94 | } |
| 102 | - std::cout << "."; | |
| 103 | - | |
| 104 | - // Signal final test success | |
| 105 | - std::cout << " ok." << std::endl; | |
| 106 | - | |
| 95 | + | |
| 107 | 96 | // Exit test |
| 108 | 97 | return; |
| 109 | 98 | |
| ... | ... | @@ -115,15 +104,22 @@ void test_GLog(void) |
| 115 | 104 | ***************************************************************************/ |
| 116 | 105 | int main(void) |
| 117 | 106 | { |
| 118 | - // Dump header | |
| 119 | - std::cout << std::endl; | |
| 120 | - std::cout << "********************************" << std::endl; | |
| 121 | - std::cout << "* GApplication classes testing *" << std::endl; | |
| 122 | - std::cout << "********************************" << std::endl; | |
| 123 | - | |
| 107 | + // Create a test suite container | |
| 108 | + GTestSuites testsuites("GApplication classes testing"); | |
| 109 | + | |
| 110 | + // Create a test suite | |
| 111 | + GTestSuite testsuite("Test GLog"); | |
| 112 | + | |
| 113 | + // Append testsuite | |
| 114 | + testsuites.append(testsuite); | |
| 115 | + | |
| 124 | 116 | // Execute tests |
| 125 | - test_GLog(); | |
| 126 | - | |
| 117 | + test_GLog(testsuite); | |
| 118 | + testsuite.end_test(); | |
| 119 | + | |
| 120 | + //save xml report | |
| 121 | + testsuites.save("reports/GApplication.xml"); | |
| 122 | + | |
| 127 | 123 | // Return |
| 128 | 124 | return 0; |
| 129 | 125 | } | ... | ... |