From: =?utf-8?q?Christian_G=C3=B6ttsche?= Date: Mon, 18 Jan 2021 17:02:49 +0100 Subject: Adjust test suite for 106-bit long double precision On PowerPC architectures (ppc, ppc64el, powerp) 'long double' has a precision of 106-bit, compared to 80-bit precision on amd64. This leads to the test_ck_assert_(float|double|ldouble)_eq_tol succeed rather than fail as expected, cause 0.003-0.002 will be actually slightly bigger than 0.001 and not slightly smaller. Increase the change to the tolerance, so it will be on all architectures smaller than the difference of ~0.001 and the unit tests will fail as expected. Forwarded: https://github.com/libcheck/check/pull/322 --- tests/check_check_master.c | 6 +++--- tests/check_check_sub.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/check_check_master.c b/tests/check_check_master.c index 781694a..8f91cfd 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -134,7 +134,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_float_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_float_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_float_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_float_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.003, t == 0.001" }, + { "Simple Tests", "test_ck_assert_float_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.003, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_float_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_float_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_float_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, @@ -174,7 +174,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_double_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_double_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_double_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_double_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.001" }, + { "Simple Tests", "test_ck_assert_double_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_double_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_double_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_double_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, @@ -214,7 +214,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_ldouble_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_ldouble_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_ldouble_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_ldouble_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.001" }, + { "Simple Tests", "test_ck_assert_ldouble_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_ldouble_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_ldouble_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_ldouble_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, diff --git a/tests/check_check_sub.c b/tests/check_check_sub.c index 184a3bf..ebf35d7 100644 --- a/tests/check_check_sub.c +++ b/tests/check_check_sub.c @@ -778,7 +778,7 @@ START_TEST(test_ck_assert_float_eq_tol) y*=10.0f; t*=10.0f; ck_assert_float_eq_tol(x, y, t); - t/=10.0f; + t/=10.1f; record_failure_line_num(__LINE__); ck_assert_float_eq_tol(x, y, t); } @@ -1294,7 +1294,7 @@ START_TEST(test_ck_assert_double_eq_tol) y*=10; t*=10; ck_assert_double_eq_tol(x, y, t); - t/=10; + t/=10.1; record_failure_line_num(__LINE__); ck_assert_double_eq_tol(x, y, t); } @@ -1812,7 +1812,7 @@ START_TEST(test_ck_assert_ldouble_eq_tol) y*=10.0l; t*=10.0l; ck_assert_ldouble_eq_tol(x, y, t); - t/=10.0l; + t/=10.1l; record_failure_line_num(__LINE__); ck_assert_ldouble_eq_tol(x, y, t); }