Commit eda3af55 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

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.
parent 727f0fea
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.
......
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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment