From 07f806697d73d746807e105ed9b876ddb12a81aa Mon Sep 17 00:00:00 2001 From: David Fioramonti Date: Sat, 6 Apr 2019 20:31:23 -0700 Subject: TESTS: Use M_PI for Common math tests Instead of defining a new variable constant pi we use M_PI. --- test/common/math.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'test/common/math.h') diff --git a/test/common/math.h b/test/common/math.h index 11d2b7e827..79c005206d 100644 --- a/test/common/math.h +++ b/test/common/math.h @@ -8,7 +8,6 @@ #define TS_ASSERT_ALMOST_EQUALS(x, y, z) \ TS_ASSERT_LESS_THAN(((x) - (y)) >= 0 ? (x) - (y) : (y) - (x), z) -const float PI = 3.141592653; const float MAX_ERROR = 0.000001; class MathTestSuite : public CxxTest::TestSuite { @@ -26,15 +25,15 @@ class MathTestSuite : public CxxTest::TestSuite void test_rad2deg() { TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(0), 0, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(PI), 180.0, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(2.0 * PI), 360.0, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(PI / 2.0), 90.0, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(M_PI), 180.0, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(2.0 * M_PI), 360.0, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::rad2deg(M_PI / 2.0), 90.0, MAX_ERROR); } void test_deg2rad() { TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(0), 0, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(180.0), PI, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(360.0), 2.0 * PI, MAX_ERROR); - TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(90.0), PI / 2.0, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(180.0), M_PI, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(360.0), 2.0 * M_PI, MAX_ERROR); + TS_ASSERT_ALMOST_EQUALS(Common::deg2rad(90.0), M_PI / 2.0, MAX_ERROR); } }; -- cgit v1.2.3