From 48fefd8c841c6b22a620d3b6d6af5d062886627f Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Thu, 20 Aug 2015 15:00:02 +0100 Subject: [PATCH] check: hlsdemux: make duration unit test robust to floating point rounding The test_playlist_with_doubles_duration() test fails on some platforms due to rounding errors that occur when m3u8.c converts from the floating point value in the HLS manifest to a GstClockTime. Using assert_equals_float() fixes this because this function handles the rounding error issues by accepting almost equal. https://bugzilla.gnome.org/show_bug.cgi?id=753881 --- tests/check/elements/hlsdemux_m3u8.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/check/elements/hlsdemux_m3u8.c b/tests/check/elements/hlsdemux_m3u8.c index 07fe6d693d..406123e92a 100644 --- a/tests/check/elements/hlsdemux_m3u8.c +++ b/tests/check/elements/hlsdemux_m3u8.c @@ -558,13 +558,13 @@ GST_START_TEST (test_playlist_with_doubles_duration) pl = client->current; /* Check first media segments */ file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 0)); - assert_equals_uint64 (file->duration, 10.321 * GST_SECOND); + assert_equals_float (file->duration / (double) GST_SECOND, 10.321); file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 1)); - assert_equals_uint64 (file->duration, 9.6789 * GST_SECOND); + assert_equals_float (file->duration / (double) GST_SECOND, 9.6789); file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 2)); - assert_equals_uint64 (file->duration, 10.2344 * GST_SECOND); + assert_equals_float (file->duration / (double) GST_SECOND, 10.2344); file = GST_M3U8_MEDIA_FILE (g_list_nth_data (pl->files, 3)); - assert_equals_uint64 (file->duration, 9.92 * GST_SECOND); + assert_equals_float (file->duration / (double) GST_SECOND, 9.92); gst_m3u8_client_free (client); }