mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-23 22:16:16 +01:00
Add test case for group removal.
2005-02-01 Matthias Clasen <mclasen@redhat.com> * tests/keyfile-test.c (test_group_remove): Add test case for group removal. * glib/gkeyfile.c (g_key_file_remove_group): Don't segfault if the group doesn't exist. (#165887, Mathias Hasselmann)
This commit is contained in:
parent
0e93338bc0
commit
df59e8e19b
@ -1,3 +1,11 @@
|
||||
2005-02-01 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_group_remove): Add test case for
|
||||
group removal.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_remove_group): Don't segfault
|
||||
if the group doesn't exist. (#165887, Mathias Hasselmann)
|
||||
|
||||
2005-01-30 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c: Some more unit tests.
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-02-01 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_group_remove): Add test case for
|
||||
group removal.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_remove_group): Don't segfault
|
||||
if the group doesn't exist. (#165887, Mathias Hasselmann)
|
||||
|
||||
2005-01-30 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c: Some more unit tests.
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-02-01 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_group_remove): Add test case for
|
||||
group removal.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_remove_group): Don't segfault
|
||||
if the group doesn't exist. (#165887, Mathias Hasselmann)
|
||||
|
||||
2005-01-30 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c: Some more unit tests.
|
||||
|
@ -1,3 +1,11 @@
|
||||
2005-02-01 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c (test_group_remove): Add test case for
|
||||
group removal.
|
||||
|
||||
* glib/gkeyfile.c (g_key_file_remove_group): Don't segfault
|
||||
if the group doesn't exist. (#165887, Mathias Hasselmann)
|
||||
|
||||
2005-01-30 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/keyfile-test.c: Some more unit tests.
|
||||
|
@ -2768,8 +2768,8 @@ g_key_file_remove_group (GKeyFile *key_file,
|
||||
G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
|
||||
_("Key file does not have group '%s'"),
|
||||
group_name);
|
||||
|
||||
g_key_file_remove_group_node (key_file, group_node);
|
||||
else
|
||||
g_key_file_remove_group_node (key_file, group_node);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -519,6 +519,8 @@ test_boolean (void)
|
||||
|
||||
g_key_file_get_boolean (keyfile, "invalid", "key4", &error);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE);
|
||||
|
||||
g_key_file_free (keyfile);
|
||||
}
|
||||
|
||||
/* check parsing of integer values */
|
||||
@ -562,6 +564,73 @@ test_integer (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_free (keyfile);
|
||||
}
|
||||
|
||||
/* http://bugzilla.gnome.org/show_bug.cgi?id=165887 */
|
||||
static void
|
||||
test_group_remove (void)
|
||||
{
|
||||
GKeyFile *keyfile;
|
||||
gchar **names;
|
||||
gsize len;
|
||||
GError *error = NULL;
|
||||
|
||||
const gchar *data =
|
||||
"[group1]\n"
|
||||
"[group2]\n"
|
||||
"key1=bla\n"
|
||||
"key2=bla\n"
|
||||
"[group3]\n"
|
||||
"key1=bla\n"
|
||||
"key2=bla\n";
|
||||
|
||||
keyfile = load_data (data, 0);
|
||||
|
||||
names = g_key_file_get_groups (keyfile, &len);
|
||||
if (names == NULL)
|
||||
{
|
||||
g_print ("Error listing groups\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
check_length ("groups", g_strv_length (names), len, 3);
|
||||
check_name ("group name", names[0], "group1", 0);
|
||||
check_name ("group name", names[1], "group2", 1);
|
||||
check_name ("group name", names[2], "group3", 2);
|
||||
|
||||
g_key_file_remove_group (keyfile, "group1", &error);
|
||||
check_no_error (&error);
|
||||
|
||||
names = g_key_file_get_groups (keyfile, &len);
|
||||
if (names == NULL)
|
||||
{
|
||||
g_print ("Error listing groups\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
check_length ("groups", g_strv_length (names), len, 2);
|
||||
check_name ("group name", names[0], "group2", 0);
|
||||
check_name ("group name", names[1], "group3", 1);
|
||||
|
||||
g_key_file_remove_group (keyfile, "group2", &error);
|
||||
check_no_error (&error);
|
||||
|
||||
names = g_key_file_get_groups (keyfile, &len);
|
||||
if (names == NULL)
|
||||
{
|
||||
g_print ("Error listing groups\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
check_length ("groups", g_strv_length (names), len, 1);
|
||||
check_name ("group name", names[0], "group3", 0);
|
||||
|
||||
g_key_file_remove_group (keyfile, "no such group", &error);
|
||||
check_error (&error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_GROUP_NOT_FOUND);
|
||||
|
||||
g_key_file_free (keyfile);
|
||||
}
|
||||
|
||||
/* check handling of translated strings */
|
||||
@ -680,6 +749,7 @@ main (int argc, char *argv[])
|
||||
test_integer ();
|
||||
test_locale_string ();
|
||||
test_lists ();
|
||||
test_group_remove ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user