[glib] glib/tests/keyfile: check return value of g_key_file_get_double is 0 for invalid values



commit 3560faadd1f6c17973c2cf61fafe2a9c451dd71b
Author: Aurélien Zanelli <aurelien zanelli parrot com>
Date:   Thu Jul 7 10:19:39 2016 +0200

    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 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c
index 5e8ee90..865368b 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);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]