mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 04:03:34 +08:00
Slight improvements in unit tests
This commit is contained in:
committed by
Daniel Agar
parent
bae3f36900
commit
8cc261a148
@@ -57,9 +57,9 @@ void UnitTest::print_results(void)
|
||||
PX4_INFO("ALL TESTS PASSED");
|
||||
}
|
||||
|
||||
PX4_INFO(" Tests passed : %d", _tests_passed);
|
||||
PX4_INFO(" Tests failed : %d", _tests_failed);
|
||||
PX4_INFO(" Assertions : %d", _assertions);
|
||||
PX4_INFO(" Tests passed : %d", _tests_passed);
|
||||
PX4_INFO(" Tests failed : %d", _tests_failed);
|
||||
PX4_INFO(" Tested assertions : %d", _assertions);
|
||||
}
|
||||
|
||||
/// @brief Used internally to the ut_assert macro to print assert failures.
|
||||
|
||||
@@ -158,6 +158,20 @@ protected:
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/// @brief Used to compare two integer values within a unit test. If possible use ut_less_than instead of ut_assert
|
||||
/// since it will give you better error reporting of the actual values being compared.
|
||||
#define ut_less_than(message, v1_smaller, v2_bigger) \
|
||||
do { \
|
||||
int _v1 = v1_smaller; \
|
||||
int _v2 = v2_bigger; \
|
||||
if (!(_v1 < _v2)) { \
|
||||
_print_compare(message, #v1_smaller, _v1, #v2_bigger, _v2, __FILE__, __LINE__); \
|
||||
return false; \
|
||||
} else { \
|
||||
_assertions++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
virtual void _init(void) { }; ///< Run before each unit test. Override to provide custom behavior.
|
||||
virtual void _cleanup(void) { }; ///< Run after each unit test. Override to provide custom behavior.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user