mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-30 05:40:35 +08:00
Rewrote to provide better feedback
Also allows variables as well as static text for assert text in ut_assert
This commit is contained in:
@@ -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)
|
||||
{
|
||||
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(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)
|
||||
{
|
||||
warnx("Assertion failed: %s - %s (%s:%d)", msg, test, file, line);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user