From 3560faadd1f6c17973c2cf61fafe2a9c451dd71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Zanelli?= Date: Thu, 7 Jul 2016 10:19:39 +0200 Subject: [PATCH] glib/tests/keyfile: check return value of g_key_file_get_double is 0 for invalid values As specified in the documentation of g_key_file_get_double function. https://bugzilla.gnome.org/show_bug.cgi?id=768504 --- glib/tests/keyfile.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c index 5e8ee90b5..865368b22 100644 --- a/glib/tests/keyfile.c +++ b/glib/tests/keyfile.c @@ -615,6 +615,7 @@ test_number (void) { GKeyFile *keyfile; GError *error = NULL; + gdouble dval = 0.0; const gchar *data = "[valid]\n" @@ -665,17 +666,21 @@ test_number (void) g_key_file_get_integer (keyfile, "invalid", "key4", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); - g_key_file_get_double (keyfile, "invalid", "key5", &error); + dval = g_key_file_get_double (keyfile, "invalid", "key5", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + g_assert_cmpfloat (dval, ==, 0.0); - g_key_file_get_double (keyfile, "invalid", "key6", &error); + dval = g_key_file_get_double (keyfile, "invalid", "key6", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + g_assert_cmpfloat (dval, ==, 0.0); - g_key_file_get_double (keyfile, "invalid", "key7", &error); + dval = g_key_file_get_double (keyfile, "invalid", "key7", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + g_assert_cmpfloat (dval, ==, 0.0); - g_key_file_get_double (keyfile, "invalid", "key8", &error); + dval = g_key_file_get_double (keyfile, "invalid", "key8", &error); check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE); + g_assert_cmpfloat (dval, ==, 0.0); g_key_file_free (keyfile); }