diff options
author | Thierry Crozat | 2019-04-12 01:33:47 +0100 |
---|---|---|
committer | Thierry Crozat | 2019-04-12 01:37:59 +0100 |
commit | 563520f5c86820db8af50d7a1739d6903930e33f (patch) | |
tree | aae12a54ddbc00f31dfe1b2b466d1079c6f50c59 /test/common/math.h | |
parent | 322af3e49ae800f45eae39e4f081197cba0b9a3f (diff) | |
download | scummvm-rg350-563520f5c86820db8af50d7a1739d6903930e33f.tar.gz scummvm-rg350-563520f5c86820db8af50d7a1739d6903930e33f.tar.bz2 scummvm-rg350-563520f5c86820db8af50d7a1739d6903930e33f.zip |
TESTS: Reduce error for double precision math test
If we want to properly test the computation is in double precision,
we should be using a much smaller error than the one used for the
single precision tests.
Diffstat (limited to 'test/common/math.h')
-rw-r--r-- | test/common/math.h | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/test/common/math.h b/test/common/math.h index 5010ca5ed2..ae7a789897 100644 --- a/test/common/math.h +++ b/test/common/math.h @@ -2,7 +2,8 @@ #include "common/math.h" -const float MAX_ERROR = 1e-7; +const float MAX_ERROR_FLT = 1e-7f; +const double MAX_ERROR_DBL = 1e-15; class MathTestSuite : public CxxTest::TestSuite { public: @@ -19,27 +20,27 @@ class MathTestSuite : public CxxTest::TestSuite void test_rad2deg() { //float verion - TS_ASSERT_DELTA(Common::rad2deg(0), 0, MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg(M_PI), 180.0, 180.0 * MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR); + TS_ASSERT_DELTA(Common::rad2deg(0), 0, MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::rad2deg(M_PI), 180.0, 180.0 * MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::rad2deg(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::rad2deg(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_FLT); //double version - TS_ASSERT_DELTA(Common::rad2deg<double>(0), 0, MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI), 180.0, 180.0 * MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg<double>(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR); - TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR); + TS_ASSERT_DELTA(Common::rad2deg<double>(0), 0, MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI), 180.0, 180.0 * MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::rad2deg<double>(2.0 * M_PI), 360.0, 360.0 * MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::rad2deg<double>(M_PI / 2.0), 90.0, 90.0 * MAX_ERROR_DBL); } void test_deg2rad() { //float verion - TS_ASSERT_DELTA(Common::deg2rad(0), 0, MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad(180.0), M_PI, M_PI * MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR); + TS_ASSERT_DELTA(Common::deg2rad(0), 0, MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::deg2rad(180.0), M_PI, M_PI * MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::deg2rad(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_FLT); + TS_ASSERT_DELTA(Common::deg2rad(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_FLT); //double version - TS_ASSERT_DELTA(Common::deg2rad<double>(0), 0, MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad<double>(180.0), M_PI, M_PI * MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad<double>(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR); - TS_ASSERT_DELTA(Common::deg2rad<double>(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR); + TS_ASSERT_DELTA(Common::deg2rad<double>(0), 0, MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::deg2rad<double>(180.0), M_PI, M_PI * MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::deg2rad<double>(360.0), 2.0 * M_PI, 2.0 * M_PI * MAX_ERROR_DBL); + TS_ASSERT_DELTA(Common::deg2rad<double>(90.0), M_PI / 2.0, M_PI / 2.0 * MAX_ERROR_DBL); } }; |