mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-29 08:56:15 +01:00
tests: Test various different invalid encoding names for key files
These exercise different branches in `g_key_file_parse_key_value_pair()`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
d2e5c61104
commit
e8a6d0b54e
@ -1675,21 +1675,32 @@ test_limbo (void)
|
|||||||
static void
|
static void
|
||||||
test_utf8 (void)
|
test_utf8 (void)
|
||||||
{
|
{
|
||||||
GKeyFile *file;
|
const gchar *invalid_encoding_names[] =
|
||||||
static const char data[] =
|
{
|
||||||
"[group]\n"
|
"non-UTF-8",
|
||||||
"Encoding=non-UTF-8\n";
|
"UTF",
|
||||||
gboolean ok;
|
"UTF-9",
|
||||||
GError *error;
|
};
|
||||||
|
gsize i;
|
||||||
|
|
||||||
file = g_key_file_new ();
|
for (i = 0; i < G_N_ELEMENTS (invalid_encoding_names); i++)
|
||||||
|
{
|
||||||
|
GKeyFile *file = NULL;
|
||||||
|
gchar *data = NULL;
|
||||||
|
gboolean ok;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
error = NULL;
|
g_test_message ("Testing invalid encoding ‘%s’", invalid_encoding_names[i]);
|
||||||
ok = g_key_file_load_from_data (file, data, strlen (data), 0, &error);
|
|
||||||
g_assert_false (ok);
|
file = g_key_file_new ();
|
||||||
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_UNKNOWN_ENCODING);
|
data = g_strdup_printf ("[group]\n"
|
||||||
g_clear_error (&error);
|
"Encoding=%s\n", invalid_encoding_names[i]);
|
||||||
g_key_file_free (file);
|
ok = g_key_file_load_from_data (file, data, strlen (data), 0, &error);
|
||||||
|
g_assert_false (ok);
|
||||||
|
g_assert_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_UNKNOWN_ENCODING);
|
||||||
|
g_clear_error (&error);
|
||||||
|
g_key_file_free (file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user