From 2ef3fb791b6ddffa56b6809e589be41f160a8a8a Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sun, 5 Mar 2023 10:21:40 +0200 Subject: =?UTF-8?q?testmatrix.c:=20Don=E2=80=99t=20use=20g=5Fassert=5Fcmph?= =?UTF-8?q?ex()=20with=20floats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The build was giving this warning: ../tests/testmatrix.c:197:27: warning: implicit conversion from 'double' to 'guint64' (aka 'unsigned long long') changes value from 0.2 to 0 [-Wliteral-conversion] g_assert_cmphex (r, ==, 0.2); ~~~~~~~~~~~~~~~~~~~~~~~~^~~~ So the test was effectively comparing 0 to 0. I switched to g_assert_cmpfloat(), but now the tests are failing as the values don’t mach. I don’t know which is wrong, the expected value or the code being tested. --- tests/testmatrix.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testmatrix.c b/tests/testmatrix.c index 1ba79839..3bbca282 100644 --- a/tests/testmatrix.c +++ b/tests/testmatrix.c @@ -194,20 +194,20 @@ test_matrix_slant_ratio (void) double r; r = pango_matrix_get_slant_ratio (&m); - g_assert_cmphex (r, ==, 0.2); + g_assert_cmpfloat (r, ==, 0.2); pango_matrix_rotate (&m, 45); r = pango_matrix_get_slant_ratio (&m); - g_assert_cmphex (r, ==, 0.2); + g_assert_cmpfloat (r, ==, 0.2); pango_matrix_scale (&m, 2, 3); r = pango_matrix_get_slant_ratio (&m); - g_assert_cmphex (r, ==, 0.2); + g_assert_cmpfloat (r, ==, 0.2); r = pango_matrix_get_slant_ratio (&m2); - g_assert_cmphex (r, ==, 0.4); + g_assert_cmpfloat (r, ==, 0.4); } int -- cgit v1.2.1