mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Add some tests for invalid floating point numbers.
2006-05-08 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c (test_number): Add some tests for invalid floating point numbers.
This commit is contained in:
parent
727f0fea57
commit
eda3af5546
@ -1,5 +1,11 @@
|
||||
2006-05-08 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_number): Add some tests for
|
||||
invalid floating point numbers.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_parse_value_as_double): Return
|
||||
an error for the empty string. (#339105, Morten Welinder)
|
||||
|
||||
* glib/gscanner.c (g_scanner_config_template): Make const,
|
||||
noticed by Kjartan Maraas.
|
||||
|
||||
|
@ -1,5 +1,11 @@
|
||||
2006-05-08 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_number): Add some tests for
|
||||
invalid floating point numbers.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_parse_value_as_double): Return
|
||||
an error for the empty string. (#339105, Morten Welinder)
|
||||
|
||||
* glib/gscanner.c (g_scanner_config_template): Make const,
|
||||
noticed by Kjartan Maraas.
|
||||
|
||||
|
@ -3471,7 +3471,7 @@ g_key_file_parse_value_as_double (GKeyFile *key_file,
|
||||
|
||||
double_value = g_ascii_strtod (value, &end_of_valid_d);
|
||||
|
||||
if (*end_of_valid_d != '\0')
|
||||
if (*end_of_valid_d != '\0' || end_of_valid_d == value)
|
||||
g_set_error (error, G_KEY_FILE_ERROR,
|
||||
G_KEY_FILE_ERROR_INVALID_VALUE,
|
||||
_("Value '%s' cannot be interpreted as a float number."), value);
|
||||
|
@ -697,7 +697,11 @@ test_number (void)
|
||||
"key1=0xffff\n"
|
||||
"key2=0.5\n"
|
||||
"key3=1e37\n"
|
||||
"key4=ten\n";
|
||||
"key4=ten\n"
|
||||
"key5=\n"
|
||||
"key6=1.0.0\n"
|
||||
"key7=2x2\n"
|
||||
"key8=abc\n";
|
||||
|
||||
keyfile = load_data (data, 0);
|
||||
|
||||
@ -723,6 +727,18 @@ 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);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
|
||||
|
||||
g_key_file_get_double (keyfile, "invalid", "key6", &error);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
|
||||
|
||||
g_key_file_get_double (keyfile, "invalid", "key7", &error);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
|
||||
|
||||
g_key_file_get_double (keyfile, "invalid", "key8", &error);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
|
||||
|
||||
g_key_file_free (keyfile);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user