From 8f1d350d3cafdabd515d09dc6e54122b9a489b1f Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Fri, 29 Jul 2016 18:21:59 +0200 Subject: [PATCH] unit_test: add ut_assert_true and ut_assert_false --- src/modules/unit_test/unit_test.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/modules/unit_test/unit_test.h b/src/modules/unit_test/unit_test.h index aeddaac88e..42be09c165 100644 --- a/src/modules/unit_test/unit_test.h +++ b/src/modules/unit_test/unit_test.h @@ -106,6 +106,28 @@ protected: /// @brief Used to assert a value within a unit test. #define ut_test(test) ut_assert("test", test) +/// @brief To assert specifically to true. +#define ut_assert_true(test) \ + do { \ + if (test != true) { \ + _print_assert("result not true", #test, __FILE__, __LINE__); \ + return false; \ + } else { \ + _assertions++; \ + } \ + } while (0) + +/// @brief To assert specifically to true. +#define ut_assert_false(test) \ + do { \ + if (test != false) { \ + _print_assert("result not false", #test, __FILE__, __LINE__); \ + return false; \ + } else { \ + _assertions++; \ + } \ + } while (0) + /// @brief Used to compare two integer values within a unit test. If possible use ut_compare instead of ut_assert /// since it will give you better error reporting of the actual values being compared. #define ut_compare(message, v1, v2) \