From: Matthias Clasen Date: Wed, 25 Jan 2012 12:26:58 +0000 (-0500) Subject: Add a test for g_key_file_set_list_separator X-Git-Tag: 2.31.14~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e50d7e065c72278f7811f7008dac80d5ce53f401;p=platform%2Fupstream%2Fglib.git Add a test for g_key_file_set_list_separator A recent 'harmless' fix broke it... --- diff --git a/glib/tests/keyfile.c b/glib/tests/keyfile.c index aac47fb..0fc9fa8 100644 --- a/glib/tests/keyfile.c +++ b/glib/tests/keyfile.c @@ -651,6 +651,7 @@ static void test_locale_string (void) { GKeyFile *keyfile; + gchar *old_locale; const gchar *data = "[valid]\n" @@ -677,8 +678,8 @@ test_locale_string (void) /* now test that translations are thrown away */ - g_setenv ("LANGUAGE", "de", TRUE); - setlocale (LC_ALL, ""); + old_locale = g_strdup (setlocale (LC_ALL, NULL)); + setlocale (LC_ALL, "de_DE.utf-8"); keyfile = load_data (data, 0); @@ -691,6 +692,9 @@ test_locale_string (void) check_locale_string_value (keyfile, "valid", "key1", "en", "v1"); g_key_file_free (keyfile); + + setlocale (LC_ALL, old_locale); + g_free (old_locale); } static void @@ -1432,6 +1436,24 @@ test_replace_value (void) g_key_file_unref (keyfile); } +static void +test_list_separator (void) +{ + GKeyFile *keyfile; + GError *error = NULL; + + const gchar *data = + "[test]\n" + "key1=v1,v2\n"; + + keyfile = g_key_file_new (); + g_key_file_set_list_separator (keyfile, ','); + g_key_file_load_from_data (keyfile, data, -1, 0, &error); + + check_string_list_value (keyfile, "valid", "key1", "v1", "v2", NULL); + g_key_file_unref (keyfile); +} + int main (int argc, char *argv[]) { @@ -1465,6 +1487,8 @@ main (int argc, char *argv[]) g_test_add_func ("/keyfile/page-boundary", test_page_boundary); g_test_add_func ("/keyfile/ref", test_ref); g_test_add_func ("/keyfile/replace-value", test_replace_value); + g_test_add_func ("/keyfile/list-separator", test_list_separator); + return g_test_run (); }