diff options
author | Don Gagne <don@thegagnes.com> | 2014-03-27 13:05:03 -0700 |
---|---|---|
committer | Don Gagne <don@thegagnes.com> | 2014-03-27 13:05:03 -0700 |
commit | d5a7e7c52b619dd8684867bf31671253684378ee (patch) | |
tree | 93c8c3bc3f142f4f1344d3e61d04a972144c57b8 /src/modules/unit_test/unit_test.cpp | |
parent | 521539897e59f495adaae481911e3a4ac847625e (diff) | |
download | px4-firmware-d5a7e7c52b619dd8684867bf31671253684378ee.tar.gz px4-firmware-d5a7e7c52b619dd8684867bf31671253684378ee.tar.bz2 px4-firmware-d5a7e7c52b619dd8684867bf31671253684378ee.zip |
Rewrote to provide better feedback
Also allows variables as well as static text for assert text in
ut_assert
Diffstat (limited to 'src/modules/unit_test/unit_test.cpp')
-rw-r--r-- | src/modules/unit_test/unit_test.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/modules/unit_test/unit_test.cpp b/src/modules/unit_test/unit_test.cpp index 64ee544a2..02d1af481 100644 --- a/src/modules/unit_test/unit_test.cpp +++ b/src/modules/unit_test/unit_test.cpp @@ -32,17 +32,10 @@ * ****************************************************************************/ -/** - * @file unit_test.cpp - * A unit test library. - * - */ - #include "unit_test.h" #include <systemlib/err.h> - UnitTest::UnitTest() { } @@ -51,15 +44,15 @@ UnitTest::~UnitTest() { } -void -UnitTest::print_results(const char* result) +void UnitTest::printResults(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()); +} + +void UnitTest::printAssert(const char* msg, const char* test, const char* file, int line) { - if (result != 0) { - warnx("Failed: %s:%d", mu_last_test(), mu_line()); - warnx("%s", result); - } else { - warnx("ALL TESTS PASSED"); - warnx(" Tests run : %d", mu_tests_run()); - warnx(" Assertion : %d", mu_assertion()); - } + warnx("Assertion failed: %s - %s (%s:%d)", msg, test, file, line); } |