From a35da91f5d53a831725bdc1106fda93890f1f3bd Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 2 Oct 2017 23:28:59 +0200 Subject: [PATCH] [DEV] etest better test of float --- etest/etest.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etest/etest.hpp b/etest/etest.hpp index b1edae9..23a50bf 100644 --- a/etest/etest.hpp +++ b/etest/etest.hpp @@ -183,12 +183,12 @@ namespace etest { ETEST_DEBUG(" [ SUB-DONE ]"); \ } while (false) -#define EXPECT_FLOAT_EQ(element, result) \ +#define EXPECT_FLOAT_EQ_DELTA(element, result, delta) \ do { \ ETEST_DEBUG(" [ SUB-RUN ] EXPECT_FLOAT_EQ(" << #element << ", " << #result << ");"); \ float ETEST_VARIABLE_TMP_res2 = (element) - (result); \ bool ETEST_VARIABLE_TMP_res = false; \ - if (ETEST_VARIABLE_TMP_res2 < 0.00001f && ETEST_VARIABLE_TMP_res2 > -0.00001f) { \ + if (ETEST_VARIABLE_TMP_res2 < delta && ETEST_VARIABLE_TMP_res2 > -delta) { \ ETEST_VARIABLE_TMP_res = true; \ } \ if (etest::g_currentTest == nullptr) { \ @@ -204,5 +204,6 @@ namespace etest { ETEST_DEBUG(" [ SUB-DONE ]"); \ } while (false) - +#define EXPECT_FLOAT_EQ(element, result) \ + EXPECT_FLOAT_EQ_DELTA(element, result, 0.00001f)