diff options
author | Don Gagne <don@thegagnes.com> | 2014-09-13 19:59:44 -0700 |
---|---|---|
committer | Don Gagne <don@thegagnes.com> | 2014-09-13 19:59:44 -0700 |
commit | deda5d0a04300f2ee67194c4fc9a60da37de722a (patch) | |
tree | 038083acc52ef4198a46065ff123184044e5e183 /src/modules/unit_test/unit_test.cpp | |
parent | 21367222379d6ae3b1c5c774942ac2aac5ca32cb (diff) | |
download | px4-firmware-deda5d0a04300f2ee67194c4fc9a60da37de722a.tar.gz px4-firmware-deda5d0a04300f2ee67194c4fc9a60da37de722a.tar.bz2 px4-firmware-deda5d0a04300f2ee67194c4fc9a60da37de722a.zip |
Upgraded unit test framework
Diffstat (limited to 'src/modules/unit_test/unit_test.cpp')
-rw-r--r-- | src/modules/unit_test/unit_test.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/modules/unit_test/unit_test.cpp b/src/modules/unit_test/unit_test.cpp index be3b9461a..b7568ce3a 100644 --- a/src/modules/unit_test/unit_test.cpp +++ b/src/modules/unit_test/unit_test.cpp @@ -36,7 +36,11 @@ #include <systemlib/err.h> -UnitTest::UnitTest() +UnitTest::UnitTest() : + _tests_run(0), + _tests_failed(0), + _tests_passed(0), + _assertions(0) { } @@ -44,20 +48,22 @@ UnitTest::~UnitTest() { } -void UnitTest::printResults(void) +void UnitTest::print_results(void) { - warnx(mu_tests_failed() ? "SOME TESTS FAILED" : "ALL TESTS PASSED"); - warnx(" Tests passed : %d", mu_tests_passed()); - warnx(" Tests failed : %d", mu_tests_failed()); - warnx(" Assertions : %d", mu_assertion()); + warnx(_tests_failed ? "SOME TESTS FAILED" : "ALL TESTS PASSED"); + warnx(" Tests passed : %d", _tests_passed); + warnx(" Tests failed : %d", _tests_failed); + warnx(" Assertions : %d", _assertions); } -void UnitTest::printAssert(const char* msg, const char* test, const char* file, int line) +/// @brief Used internally to the ut_assert macro to print assert failures. +void UnitTest::_print_assert(const char* msg, const char* test, const char* file, int line) { - warnx("Assertion failed: %s - %s (%s:%d)", msg, test, file, line); + warnx("Assertion failed: %s - %s (%s:%d)", msg, test, file, line); } -void UnitTest::printCompare(const char* msg, const char *v1_text, int v1, const char *v2_text, int v2, const char* file, int line) +/// @brief Used internally to the ut_compare macro to print assert failures. +void UnitTest::_print_compare(const char* msg, const char *v1_text, int v1, const char *v2_text, int v2, const char* file, int line) { warnx("Compare failed: %s - (%s:%d) (%s:%d) (%s:%d)", msg, v1_text, v1, v2_text, v2, file, line); } |