From 348b07609c7fec31cd377202145f150d3d9ffb62 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 2 May 2016 15:40:53 -0300 Subject: [PATCH] AP_Math: remove macros from unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid warnings like: [2130/2168] Compiling libraries/AP_Math/tests/test_math.cpp ../../libraries/AP_Math/tests/test_math.cpp: In member function ‘virtual void MathTest_IsZero_Test::TestBody()’: ../../libraries/AP_Math/tests/test_math.cpp:73:196: warning: converting ‘false’ to pointer type for argument 1 of ‘char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null] ../../libraries/AP_Math/tests/test_math.cpp:74:199: warning: converting ‘false’ to pointer type for argument 1 of ‘char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)’ [-Wconversion-null] Use EXPECT_TRUE() and EXPECT_FALSE() from gtest instead. --- libraries/AP_Math/tests/test_math.cpp | 28 +++++++++------------------ 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/libraries/AP_Math/tests/test_math.cpp b/libraries/AP_Math/tests/test_math.cpp index 59f48206e2..1254164093 100644 --- a/libraries/AP_Math/tests/test_math.cpp +++ b/libraries/AP_Math/tests/test_math.cpp @@ -65,29 +65,19 @@ TEST(VectorTest, Rotations) TEST(MathTest, IsZero) { -#define TEST_IS_ZERO(_result, _test) { \ - bool bZero = is_zero(_test); \ - EXPECT_EQ(_result, bZero) << "is_zero(): floating point is_zero comparator failure"; \ -} - - TEST_IS_ZERO(false, 0.1); - TEST_IS_ZERO(false, 0.0001); - TEST_IS_ZERO(true, 0.f); - TEST_IS_ZERO(true, FLT_MIN); - TEST_IS_ZERO(true, -FLT_MIN); + EXPECT_FALSE(is_zero(0.1)); + EXPECT_FALSE(is_zero(0.0001)); + EXPECT_TRUE(is_zero(0.f)); + EXPECT_TRUE(is_zero(FLT_MIN)); + EXPECT_TRUE(is_zero(-FLT_MIN)); } TEST(MathTest, IsEqual) { -#define TEST_IS_EQUAL(_result, _test1, _test2) { \ - bool bEqual = is_equal(_test1, _test2); \ - EXPECT_EQ(_result, bEqual) << "is_equal(): floating point is_equal comparator failure"; \ -} - - TEST_IS_EQUAL(false, 0.1, 0.10001); - TEST_IS_EQUAL(false, 0.1, -0.1001); - TEST_IS_EQUAL(true, 0.f, 0.0f); - TEST_IS_EQUAL(false, 1.f, 1.f + FLT_EPSILON); + EXPECT_FALSE(is_equal(0.1, 0.10001)); + EXPECT_FALSE(is_equal(0.1, -0.1001)); + EXPECT_TRUE(is_equal(0.f, 0.0f)); + EXPECT_FALSE(is_equal(1.f, 1.f + FLT_EPSILON)); } TEST(MathTest, Square)