86#include <gtest/gtest.h>
89#if !(HX_USE_MACROS_WITH_MODULE)
92#include "detail/hxtest_detail.hpp"
113#define HX_TEST_NAME_(x_, y_, z_) x_ ## y_ ## __ ## z_ ## _
120#define TEST(suite_name_, case_name_) \
121 static void HX_TEST_NAME_(hxtest_, suite_name_, case_name_)(void); \
122 static HX_NS_PREFIX_ hxdetail_::hxtest_case_ HX_TEST_NAME_(hxs_test_, suite_name_, case_name_)( \
123 HX_TEST_NAME_(hxtest_, suite_name_, case_name_), #suite_name_, #case_name_, __FILE__, __LINE__); \
124 static void HX_TEST_NAME_(hxtest_, suite_name_, case_name_)(void)
131#define TEST_F(suite_fixture_, case_name_) \
132 class HX_TEST_NAME_(hxtest_f_, suite_fixture_, case_name_) : public suite_fixture_ { \
134 static void hxrun_(void) { \
135 HX_TEST_NAME_(hxtest_f_, suite_fixture_, case_name_) subclass_; \
137 subclass_.hxrun_test_f_(); \
138 subclass_.TearDown(); \
141 void hxrun_test_f_(void); \
143 static HX_NS_PREFIX_ hxdetail_::hxtest_case_ HX_TEST_NAME_(hxs_test_f_, suite_fixture_, case_name_)( \
144 HX_TEST_NAME_(hxtest_f_, suite_fixture_, case_name_)::hxrun_, #suite_fixture_, #case_name_, __FILE__, __LINE__); \
145 void HX_TEST_NAME_(hxtest_f_, suite_fixture_, case_name_)::hxrun_test_f_(void)
149#define RUN_ALL_TESTS() HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().run_all_tests_()
153#define SUCCEED() HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
154 true, __FILE__, __LINE__, "SUCCEED()", false)
158#define FAIL() do { HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
159 false, __FILE__, __LINE__, "FAIL()", false); return; } while (0)
161#define ADD_FAILURE() HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
162 false, __FILE__, __LINE__, "ADD_FAILURE()", false)
165#define ADD_FAILURE_AT(file_, line_) \
166 HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
167 false, (file_), static_cast<int>(line_), "ADD_FAILURE_AT()", false)
170#define EXPECT_TRUE(x_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
171 (x_), __FILE__, __LINE__, #x_, false)
173#define EXPECT_FALSE(x_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
174 !(x_), __FILE__, __LINE__, "!" #x_, false)
180#define EXPECT_NEAR(expected_, actual_, absolute_range_) do { \
181 const auto hxexp_ = (expected_); const auto hxact_ = (actual_); \
182 HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
183 ((hxexp_ < hxact_) ? (hxact_ - hxexp_) : (hxexp_ - hxact_)) <= (absolute_range_), \
184 __FILE__, __LINE__, "abs(" #expected_ "-" #actual_ ") <= " #absolute_range_, false); \
187#define EXPECT_LT(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
188 (a_) < (b_), __FILE__, __LINE__, #a_ " < " #b_, false)
190#define EXPECT_GT(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
191 (b_) < (a_), __FILE__, __LINE__, #a_ " > " #b_, false)
193#define EXPECT_LE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
194 !((b_) < (a_)), __FILE__, __LINE__, #a_ " <= " #b_, false)
196#define EXPECT_GE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
197 !((a_) < (b_)), __FILE__, __LINE__, #a_ " >= " #b_, false)
199#define EXPECT_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
200 (a_) == (b_), __FILE__, __LINE__, #a_ " == " #b_, false)
202#define EXPECT_NE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
203 !((a_) == (b_)), __FILE__, __LINE__, #a_ " != " #b_, false)
206#define EXPECT_FLOAT_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
207 HX_NS_PREFIX_ hxdetail_::hxtest_float_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " ~= " #b_, false)
210#define EXPECT_DOUBLE_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
211 HX_NS_PREFIX_ hxdetail_::hxtest_double_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " ~= " #b_, false)
214#define EXPECT_STREQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
215 HX_NS_PREFIX_ hxdetail_::hxtest_str_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " == " #b_, false)
218#define EXPECT_STRNE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
219 HX_NS_PREFIX_ hxdetail_::hxtest_str_ne_((a_), (b_)), __FILE__, __LINE__, #a_ " != " #b_, false)
221#define ASSERT_TRUE(x_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
222 (x_), __FILE__, __LINE__, #x_, true)
224#define ASSERT_FALSE(x_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
225 !(x_), __FILE__, __LINE__, "!" #x_, true)
231#define ASSERT_NEAR(expected_, actual_, absolute_error_) do { \
232 const auto hxexp_ = (expected_); const auto hxact_ = (actual_); \
233 HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
234 ((hxexp_ < hxact_) ? (hxact_ - hxexp_) : (hxexp_ - hxact_)) <= (absolute_error_), \
235 __FILE__, __LINE__, "abs(" #expected_ " - " #actual_ ") <= " #absolute_error_, true); \
238#define ASSERT_LT(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
239 (a_) < (b_), __FILE__, __LINE__, #a_ " < " #b_, true)
241#define ASSERT_GT(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
242 (b_) < (a_), __FILE__, __LINE__, #a_ " > " #b_, true)
244#define ASSERT_LE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
245 !((b_) < (a_)), __FILE__, __LINE__, #a_ " <= " #b_, true)
247#define ASSERT_GE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
248 !((a_) < (b_)), __FILE__, __LINE__, #a_ " >= " #b_, true)
250#define ASSERT_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
251 (a_) == (b_), __FILE__, __LINE__, #a_ " == " #b_, true)
253#define ASSERT_NE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
254 !((a_) == (b_)), __FILE__, __LINE__, #a_ " != " #b_, true)
257#define ASSERT_FLOAT_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
258 HX_NS_PREFIX_ hxdetail_::hxtest_float_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " ~= " #b_, true)
261#define ASSERT_DOUBLE_EQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
262 HX_NS_PREFIX_ hxdetail_::hxtest_double_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " ~= " #b_, true)
265#define ASSERT_STREQ(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
266 HX_NS_PREFIX_ hxdetail_::hxtest_str_eq_((a_), (b_)), __FILE__, __LINE__, #a_ " == " #b_, true)
269#define ASSERT_STRNE(a_, b_) HX_NS_PREFIX_ hxdetail_::hxtest_::dispatcher_().condition_check_( \
270 HX_NS_PREFIX_ hxdetail_::hxtest_str_ne_((a_), (b_)), __FILE__, __LINE__, #a_ " != " #b_, true)
Test - Base class for tests required by Google Test's TEST_F.
Definition hxtest.hpp:99
void TearDown(void)
User overridable for tests using TEST_F.
Definition hxtest.hpp:105
void SetUp(void)
User overridable for tests using TEST_F.
Definition hxtest.hpp:102
#define hxinline
hxinline - Force a function to be inlined into its callers.
Definition hxsettings.h:125
Implements std::vector, std::inplace_vector and std::back_insert_iterator with a few things added and...
Provides core macros, memory management and feature detection.
testing - A partial Google Test reimplementation.
Definition hxtest.hpp:96