The double precision variable 'elapsed' (computed from an guint64 by division by 1e6) must be "rounded up" in order to pass the test for equality reliably.
Signed-off-by: Ingo Brückl <i...@wupperonline.de> --- glib/tests/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/glib/tests/timer.c b/glib/tests/timer.c index 18a762f..f165301 100644 --- a/glib/tests/timer.c +++ b/glib/tests/timer.c @@ -36,7 +36,7 @@ test_timer_basic (void) elapsed = g_timer_elapsed (timer, µs); g_assert_cmpfloat (elapsed, <, 1.0); - g_assert_cmpuint (micros, ==, ((guint64)(elapsed * 1e6)) % 1000000); + g_assert_cmpuint (micros, ==, ((guint64)((elapsed + 0.0000005) * 1e6)) % 1000000); g_timer_destroy (timer); } @@ -56,7 +56,7 @@ test_timer_stop (void) g_usleep (100); elapsed2 = g_timer_elapsed (timer, NULL); - g_assert_cmpfloat (elapsed, ==, elapsed2); + g_assert_cmpfloat ((float)elapsed, ==, (float)elapsed2); g_timer_destroy (timer); } -- 2.8.2 _______________________________________________ gtk-devel-list mailing list gtk-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-devel-list