3 #include <glib/gstdio.h>
9 load_data (const gchar
*data
,
15 keyfile
= g_key_file_new ();
16 g_key_file_load_from_data (keyfile
, data
, -1, flags
, &error
);
17 g_assert_no_error (error
);
22 check_error (GError
**error
,
26 g_assert_error (*error
, domain
, code
);
27 g_error_free (*error
);
32 check_no_error (GError
**error
)
34 g_assert_no_error (*error
);
38 check_string_value (GKeyFile
*keyfile
,
41 const gchar
*expected
)
46 value
= g_key_file_get_string (keyfile
, group
, key
, &error
);
47 check_no_error (&error
);
48 g_assert (value
!= NULL
);
49 g_assert_cmpstr (value
, ==, expected
);
54 check_locale_string_value (GKeyFile
*keyfile
,
58 const gchar
*expected
)
63 value
= g_key_file_get_locale_string (keyfile
, group
, key
, locale
, &error
);
64 check_no_error (&error
);
65 g_assert (value
!= NULL
);
66 g_assert_cmpstr (value
, ==, expected
);
71 check_string_locale_value (GKeyFile
*keyfile
,
75 const gchar
*expected
)
79 value
= g_key_file_get_locale_for_key (keyfile
, group
, key
, locale
);
80 g_assert_cmpstr (value
, ==, expected
);
85 check_string_list_value (GKeyFile
*keyfile
,
96 value
= g_key_file_get_string_list (keyfile
, group
, key
, &len
, &error
);
97 check_no_error (&error
);
98 g_assert (value
!= NULL
);
100 va_start (args
, key
);
102 v
= va_arg (args
, gchar
*);
105 g_assert (value
[i
] != NULL
);
106 g_assert_cmpstr (v
, ==, value
[i
]);
108 v
= va_arg (args
, gchar
*);
117 check_locale_string_list_value (GKeyFile
*keyfile
,
127 GError
*error
= NULL
;
129 value
= g_key_file_get_locale_string_list (keyfile
, group
, key
, locale
, &len
, &error
);
130 check_no_error (&error
);
131 g_assert (value
!= NULL
);
133 va_start (args
, locale
);
135 v
= va_arg (args
, gchar
*);
138 g_assert (value
[i
] != NULL
);
139 g_assert_cmpstr (v
, ==, value
[i
]);
141 v
= va_arg (args
, gchar
*);
150 check_integer_list_value (GKeyFile
*keyfile
,
159 GError
*error
= NULL
;
161 value
= g_key_file_get_integer_list (keyfile
, group
, key
, &len
, &error
);
162 check_no_error (&error
);
163 g_assert (value
!= NULL
);
165 va_start (args
, key
);
167 v
= va_arg (args
, gint
);
170 g_assert_cmpint (i
, <, len
);
171 g_assert_cmpint (value
[i
], ==, v
);
173 v
= va_arg (args
, gint
);
182 check_double_list_value (GKeyFile
*keyfile
,
191 GError
*error
= NULL
;
193 value
= g_key_file_get_double_list (keyfile
, group
, key
, &len
, &error
);
194 check_no_error (&error
);
195 g_assert (value
!= NULL
);
197 va_start (args
, key
);
199 v
= va_arg (args
, gdouble
);
202 g_assert_cmpint (i
, <, len
);
203 g_assert_cmpfloat (value
[i
], ==, v
);
205 v
= va_arg (args
, gdouble
);
214 check_boolean_list_value (GKeyFile
*keyfile
,
223 GError
*error
= NULL
;
225 value
= g_key_file_get_boolean_list (keyfile
, group
, key
, &len
, &error
);
226 check_no_error (&error
);
227 g_assert (value
!= NULL
);
229 va_start (args
, key
);
231 v
= va_arg (args
, gboolean
);
234 g_assert_cmpint (i
, <, len
);
235 g_assert_cmpint (value
[i
], ==, v
);
237 v
= va_arg (args
, gboolean
);
246 check_boolean_value (GKeyFile
*keyfile
,
251 GError
*error
= NULL
;
254 value
= g_key_file_get_boolean (keyfile
, group
, key
, &error
);
255 check_no_error (&error
);
256 g_assert_cmpint (value
, ==, expected
);
260 check_integer_value (GKeyFile
*keyfile
,
265 GError
*error
= NULL
;
268 value
= g_key_file_get_integer (keyfile
, group
, key
, &error
);
269 check_no_error (&error
);
270 g_assert_cmpint (value
, ==, expected
);
274 check_double_value (GKeyFile
*keyfile
,
279 GError
*error
= NULL
;
282 value
= g_key_file_get_double (keyfile
, group
, key
, &error
);
283 check_no_error (&error
);
284 g_assert_cmpfloat (value
, ==, expected
);
288 check_name (const gchar
*what
,
290 const gchar
*expected
,
293 g_assert_cmpstr (value
, ==, expected
);
297 check_length (const gchar
*what
,
302 g_assert_cmpint (n_items
, ==, length
);
303 g_assert_cmpint (n_items
, ==, expected
);
307 /* check that both \n and \r\n are accepted as line ends,
308 * and that stray \r are passed through
311 test_line_ends (void)
323 keyfile
= load_data (data
, 0);
325 check_string_value (keyfile
, "group1", "key1", "value1");
326 check_string_value (keyfile
, "group1", "key2", "value2");
327 check_string_value (keyfile
, "group2", "key3", "value3\r");
328 check_string_value (keyfile
, "group2", "key4", "value4");
330 g_key_file_free (keyfile
);
333 /* check handling of whitespace
336 test_whitespace (void)
349 keyfile
= load_data (data
, 0);
351 check_string_value (keyfile
, "group1", "key1", "value1");
352 check_string_value (keyfile
, "group1", "key2", "value2");
353 check_string_value (keyfile
, " group2 ", "key3", "value3 ");
354 check_string_value (keyfile
, " group2 ", "key4", "value \t4");
355 check_string_value (keyfile
, " group2 ", "key5", "value5");
357 g_key_file_free (keyfile
);
360 /* check handling of comments
368 GError
*error
= NULL
;
373 "# top comment, continued\n"
377 "# key comment, continued\n"
379 "# line end check\r\n"
383 "# group comment, continued\n"
386 const gchar
*top_comment
= " top comment\n top comment, continued\n";
387 const gchar
*group_comment
= " group comment\n group comment, continued\n";
388 const gchar
*key_comment
= " key comment\n key comment, continued\n";
390 keyfile
= load_data (data
, 0);
392 check_string_value (keyfile
, "group1", "key1", "value1");
393 check_string_value (keyfile
, "group1", "key2", "value2");
394 check_string_value (keyfile
, "group1", "key3", "value3");
395 check_string_value (keyfile
, "group1", "key4", "value4");
397 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
398 check_no_error (&error
);
400 check_length ("keys", g_strv_length (names
), len
, 4);
401 check_name ("key", names
[0], "key1", 0);
402 check_name ("key", names
[1], "key2", 1);
403 check_name ("key", names
[2], "key3", 2);
404 check_name ("key", names
[3], "key4", 3);
408 g_key_file_free (keyfile
);
410 keyfile
= load_data (data
, G_KEY_FILE_KEEP_COMMENTS
);
412 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
413 check_no_error (&error
);
415 check_length ("keys", g_strv_length (names
), len
, 4);
416 check_name ("key", names
[0], "key1", 0);
417 check_name ("key", names
[1], "key2", 1);
418 check_name ("key", names
[2], "key3", 2);
419 check_name ("key", names
[3], "key4", 3);
423 comment
= g_key_file_get_comment (keyfile
, NULL
, NULL
, &error
);
424 check_no_error (&error
);
425 check_name ("top comment", comment
, top_comment
, 0);
428 comment
= g_key_file_get_comment (keyfile
, "group1", "key2", &error
);
429 check_no_error (&error
);
430 check_name ("key comment", comment
, key_comment
, 0);
433 g_key_file_remove_comment (keyfile
, "group1", "key2", &error
);
434 check_no_error (&error
);
435 comment
= g_key_file_get_comment (keyfile
, "group1", "key2", &error
);
436 check_no_error (&error
);
437 g_assert (comment
== NULL
);
439 comment
= g_key_file_get_comment (keyfile
, "group2", NULL
, &error
);
440 check_no_error (&error
);
441 check_name ("group comment", comment
, group_comment
, 0);
444 comment
= g_key_file_get_comment (keyfile
, "group3", NULL
, &error
);
447 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
448 g_assert (comment
== NULL
);
450 g_key_file_free (keyfile
);
454 /* check key and group listing */
462 GError
*error
= NULL
;
472 keyfile
= load_data (data
, 0);
474 names
= g_key_file_get_groups (keyfile
, &len
);
475 g_assert (names
!= NULL
);
477 check_length ("groups", g_strv_length (names
), len
, 2);
478 check_name ("group name", names
[0], "group1", 0);
479 check_name ("group name", names
[1], "group2", 1);
483 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
484 check_no_error (&error
);
486 check_length ("keys", g_strv_length (names
), len
, 2);
487 check_name ("key", names
[0], "key1", 0);
488 check_name ("key", names
[1], "key2", 1);
492 names
= g_key_file_get_keys (keyfile
, "no-such-group", &len
, &error
);
493 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
497 g_assert (g_key_file_has_group (keyfile
, "group1"));
498 g_assert (g_key_file_has_group (keyfile
, "group2"));
499 g_assert (!g_key_file_has_group (keyfile
, "group10"));
500 g_assert (!g_key_file_has_group (keyfile
, "group20"));
502 start
= g_key_file_get_start_group (keyfile
);
503 g_assert_cmpstr (start
, ==, "group1");
506 g_assert (g_key_file_has_key (keyfile
, "group1", "key1", &error
));
507 check_no_error (&error
);
508 g_assert (g_key_file_has_key (keyfile
, "group2", "key3", &error
));
509 check_no_error (&error
);
510 g_assert (!g_key_file_has_key (keyfile
, "group2", "no-such-key", NULL
));
512 g_key_file_has_key (keyfile
, "no-such-group", "key", &error
);
513 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
515 g_key_file_free (keyfile
);
518 /* check parsing of string values */
523 GError
*error
= NULL
;
525 const gchar
* const list
[3] = {
532 "key1=\\s\\n\\t\\r\\\\\n"
535 "key4=\xe2\x89\xa0\xe2\x89\xa0\n"
536 "key5= leading space\n"
537 "key6=trailing space \n"
539 "key1=\\a\\b\\0800xff\n"
542 keyfile
= load_data (data
, 0);
544 check_string_value (keyfile
, "valid", "key1", " \n\t\r\\");
545 check_string_value (keyfile
, "valid", "key2", "\"quoted\"");
546 check_string_value (keyfile
, "valid", "key3", "'quoted'");
547 check_string_value (keyfile
, "valid", "key4", "\xe2\x89\xa0\xe2\x89\xa0");
548 check_string_value (keyfile
, "valid", "key5", "leading space");
549 check_string_value (keyfile
, "valid", "key6", "trailing space ");
551 value
= g_key_file_get_string (keyfile
, "invalid", "key1", &error
);
552 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
555 value
= g_key_file_get_string (keyfile
, "invalid", "key2", &error
);
556 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
559 g_key_file_set_string (keyfile
, "inserted", "key1", "simple");
560 g_key_file_set_string (keyfile
, "inserted", "key2", " leading space");
561 g_key_file_set_string (keyfile
, "inserted", "key3", "\tleading tab");
562 g_key_file_set_string (keyfile
, "inserted", "key4", "new\nline");
563 g_key_file_set_string (keyfile
, "inserted", "key5", "carriage\rreturn");
564 g_key_file_set_string (keyfile
, "inserted", "key6", "slash\\yay!");
565 g_key_file_set_string_list (keyfile
, "inserted", "key7", list
, 3);
567 check_string_value (keyfile
, "inserted", "key1", "simple");
568 check_string_value (keyfile
, "inserted", "key2", " leading space");
569 check_string_value (keyfile
, "inserted", "key3", "\tleading tab");
570 check_string_value (keyfile
, "inserted", "key4", "new\nline");
571 check_string_value (keyfile
, "inserted", "key5", "carriage\rreturn");
572 check_string_value (keyfile
, "inserted", "key6", "slash\\yay!");
573 check_string_list_value (keyfile
, "inserted", "key7", "one", "two;andahalf", "3", NULL
);
575 g_key_file_free (keyfile
);
578 /* check parsing of boolean values */
583 GError
*error
= NULL
;
599 keyfile
= load_data (data
, 0);
601 check_boolean_value (keyfile
, "valid", "key1", TRUE
);
602 check_boolean_value (keyfile
, "valid", "key2", FALSE
);
603 check_boolean_value (keyfile
, "valid", "key3", TRUE
);
604 check_boolean_value (keyfile
, "valid", "key4", FALSE
);
605 check_boolean_value (keyfile
, "valid", "key5", TRUE
);
606 check_boolean_value (keyfile
, "valid", "key6", TRUE
);
608 g_key_file_get_boolean (keyfile
, "invalid", "key1", &error
);
609 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
611 g_key_file_get_boolean (keyfile
, "invalid", "key2", &error
);
612 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
614 g_key_file_get_boolean (keyfile
, "invalid", "key3", &error
);
615 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
617 g_key_file_get_boolean (keyfile
, "invalid", "key4", &error
);
618 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
620 g_key_file_set_boolean (keyfile
, "valid", "key1", FALSE
);
621 check_boolean_value (keyfile
, "valid", "key1", FALSE
);
623 g_key_file_free (keyfile
);
626 /* check parsing of integer and double values */
631 GError
*error
= NULL
;
657 keyfile
= load_data (data
, 0);
659 check_integer_value (keyfile
, "valid", "key1", 0);
660 check_integer_value (keyfile
, "valid", "key2", 1);
661 check_integer_value (keyfile
, "valid", "key3", -1);
662 check_integer_value (keyfile
, "valid", "key4", 2324431);
663 check_integer_value (keyfile
, "valid", "key5", -2324431);
664 check_integer_value (keyfile
, "valid", "key6", 111);
665 check_integer_value (keyfile
, "valid", "key7", 1);
666 check_integer_value (keyfile
, "valid", "key8", 1);
667 check_double_value (keyfile
, "valid", "dkey1", 111.0);
668 check_double_value (keyfile
, "valid", "dkey2", 145.45);
669 check_double_value (keyfile
, "valid", "dkey3", -3453.7);
671 g_key_file_get_integer (keyfile
, "invalid", "key1", &error
);
672 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
674 g_key_file_get_integer (keyfile
, "invalid", "key2", &error
);
675 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
677 g_key_file_get_integer (keyfile
, "invalid", "key3", &error
);
678 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
680 g_key_file_get_integer (keyfile
, "invalid", "key4", &error
);
681 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
683 dval
= g_key_file_get_double (keyfile
, "invalid", "key5", &error
);
684 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
685 g_assert_cmpfloat (dval
, ==, 0.0);
687 dval
= g_key_file_get_double (keyfile
, "invalid", "key6", &error
);
688 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
689 g_assert_cmpfloat (dval
, ==, 0.0);
691 dval
= g_key_file_get_double (keyfile
, "invalid", "key7", &error
);
692 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
693 g_assert_cmpfloat (dval
, ==, 0.0);
695 dval
= g_key_file_get_double (keyfile
, "invalid", "key8", &error
);
696 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
697 g_assert_cmpfloat (dval
, ==, 0.0);
699 g_key_file_free (keyfile
);
702 /* check handling of translated strings */
704 test_locale_string (void)
713 "key1[de_DE]=v1-de_DE\n"
714 "key1[de_DE.UTF8]=v1-de_DE.UTF8\n"
717 "key1[sr@Latn]=v1-sr\n";
719 keyfile
= load_data (data
, G_KEY_FILE_KEEP_TRANSLATIONS
);
721 check_locale_string_value (keyfile
, "valid", "key1", "it", "v1");
722 check_locale_string_value (keyfile
, "valid", "key1", "de", "v1-de");
723 check_locale_string_value (keyfile
, "valid", "key1", "de_DE", "v1-de_DE");
724 check_locale_string_value (keyfile
, "valid", "key1", "de_DE.UTF8", "v1-de_DE.UTF8");
725 check_locale_string_value (keyfile
, "valid", "key1", "fr", "v1-fr");
726 check_locale_string_value (keyfile
, "valid", "key1", "fr_FR", "v1-fr");
727 check_locale_string_value (keyfile
, "valid", "key1", "en", "v1-en");
728 check_locale_string_value (keyfile
, "valid", "key1", "sr@Latn", "v1-sr");
730 g_key_file_free (keyfile
);
732 /* now test that translations are thrown away */
734 old_locale
= g_strdup (setlocale (LC_ALL
, NULL
));
735 g_setenv ("LANGUAGE", "de", TRUE
);
736 setlocale (LC_ALL
, "");
738 keyfile
= load_data (data
, 0);
740 check_locale_string_value (keyfile
, "valid", "key1", "it", "v1");
741 check_locale_string_value (keyfile
, "valid", "key1", "de", "v1-de");
742 check_locale_string_value (keyfile
, "valid", "key1", "de_DE", "v1-de");
743 check_locale_string_value (keyfile
, "valid", "key1", "de_DE.UTF8", "v1-de");
744 check_locale_string_value (keyfile
, "valid", "key1", "fr", "v1");
745 check_locale_string_value (keyfile
, "valid", "key1", "fr_FR", "v1");
746 check_locale_string_value (keyfile
, "valid", "key1", "en", "v1");
748 g_key_file_free (keyfile
);
750 setlocale (LC_ALL
, old_locale
);
767 "key7= 1 ; 0 ; -1 \n"
769 "key9=0;1.3456;-76532.456\n";
771 keyfile
= load_data (data
, 0);
773 check_string_list_value (keyfile
, "valid", "key1", "v1", "v2", NULL
);
774 check_string_list_value (keyfile
, "valid", "key2", "v1", "v2", NULL
);
775 check_string_list_value (keyfile
, "valid", "key3", "v1,v2", NULL
);
776 check_string_list_value (keyfile
, "valid", "key4", "v1;v2", NULL
);
777 check_boolean_list_value (keyfile
, "valid", "key5", TRUE
, FALSE
, -100);
778 check_integer_list_value (keyfile
, "valid", "key6", 1, 0, -1, -100);
779 check_double_list_value (keyfile
, "valid", "key9", 0.0, 1.3456, -76532.456, -100.0);
780 /* maybe these should be valid */
781 /* check_integer_list_value (keyfile, "valid", "key7", 1, 0, -1, -100);*/
782 /* check_string_list_value (keyfile, "valid", "key8", "v1\\,v2", NULL);*/
784 g_key_file_free (keyfile
);
786 /* Now check an alternate separator */
788 keyfile
= load_data (data
, 0);
789 g_key_file_set_list_separator (keyfile
, ',');
791 check_string_list_value (keyfile
, "valid", "key1", "v1;v2", NULL
);
792 check_string_list_value (keyfile
, "valid", "key2", "v1;v2;", NULL
);
793 check_string_list_value (keyfile
, "valid", "key3", "v1", "v2", NULL
);
795 g_key_file_free (keyfile
);
799 test_lists_set_get (void)
802 static const char * const strings
[] = { "v1", "v2" };
803 static const char * const locale_strings
[] = { "v1-l", "v2-l" };
804 static int integers
[] = { 1, -1, 2 };
805 static gdouble doubles
[] = { 3.14, 2.71 };
807 keyfile
= g_key_file_new ();
808 g_key_file_set_string_list (keyfile
, "group0", "key1", strings
, G_N_ELEMENTS (strings
));
809 g_key_file_set_locale_string_list (keyfile
, "group0", "key1", "de", locale_strings
, G_N_ELEMENTS (locale_strings
));
810 g_key_file_set_integer_list (keyfile
, "group0", "key2", integers
, G_N_ELEMENTS (integers
));
811 g_key_file_set_double_list (keyfile
, "group0", "key3", doubles
, G_N_ELEMENTS (doubles
));
813 check_string_list_value (keyfile
, "group0", "key1", strings
[0], strings
[1], NULL
);
814 check_locale_string_list_value (keyfile
, "group0", "key1", "de", locale_strings
[0], locale_strings
[1], NULL
);
815 check_integer_list_value (keyfile
, "group0", "key2", integers
[0], integers
[1], -100);
816 check_double_list_value (keyfile
, "group0", "key3", doubles
[0], doubles
[1], -100.0);
817 g_key_file_free (keyfile
);
819 /* and again with a different list separator */
820 keyfile
= g_key_file_new ();
821 g_key_file_set_list_separator (keyfile
, ',');
822 g_key_file_set_string_list (keyfile
, "group0", "key1", strings
, G_N_ELEMENTS (strings
));
823 g_key_file_set_locale_string_list (keyfile
, "group0", "key1", "de", locale_strings
, G_N_ELEMENTS (locale_strings
));
824 g_key_file_set_integer_list (keyfile
, "group0", "key2", integers
, G_N_ELEMENTS (integers
));
825 g_key_file_set_double_list (keyfile
, "group0", "key3", doubles
, G_N_ELEMENTS (doubles
));
827 check_string_list_value (keyfile
, "group0", "key1", strings
[0], strings
[1], NULL
);
828 check_locale_string_list_value (keyfile
, "group0", "key1", "de", locale_strings
[0], locale_strings
[1], NULL
);
829 check_integer_list_value (keyfile
, "group0", "key2", integers
[0], integers
[1], -100);
830 check_double_list_value (keyfile
, "group0", "key3", doubles
[0], doubles
[1], -100.0);
831 g_key_file_free (keyfile
);
835 test_group_remove (void)
840 GError
*error
= NULL
;
851 g_test_bug ("165887");
853 keyfile
= load_data (data
, 0);
855 names
= g_key_file_get_groups (keyfile
, &len
);
856 g_assert (names
!= NULL
);
858 check_length ("groups", g_strv_length (names
), len
, 3);
859 check_name ("group name", names
[0], "group1", 0);
860 check_name ("group name", names
[1], "group2", 1);
861 check_name ("group name", names
[2], "group3", 2);
863 g_key_file_remove_group (keyfile
, "group1", &error
);
864 check_no_error (&error
);
868 names
= g_key_file_get_groups (keyfile
, &len
);
869 g_assert (names
!= NULL
);
871 check_length ("groups", g_strv_length (names
), len
, 2);
872 check_name ("group name", names
[0], "group2", 0);
873 check_name ("group name", names
[1], "group3", 1);
875 g_key_file_remove_group (keyfile
, "group2", &error
);
876 check_no_error (&error
);
880 names
= g_key_file_get_groups (keyfile
, &len
);
881 g_assert (names
!= NULL
);
883 check_length ("groups", g_strv_length (names
), len
, 1);
884 check_name ("group name", names
[0], "group3", 0);
886 g_key_file_remove_group (keyfile
, "no such group", &error
);
887 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
891 g_key_file_free (keyfile
);
895 test_key_remove (void)
899 GError
*error
= NULL
;
906 g_test_bug ("165980");
908 keyfile
= load_data (data
, 0);
910 check_string_value (keyfile
, "group1", "key1", "bla");
912 g_key_file_remove_key (keyfile
, "group1", "key1", &error
);
913 check_no_error (&error
);
915 value
= g_key_file_get_string (keyfile
, "group1", "key1", &error
);
916 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
919 g_key_file_remove_key (keyfile
, "group1", "key1", &error
);
920 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
922 g_key_file_remove_key (keyfile
, "no such group", "key1", &error
);
923 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
925 g_key_file_free (keyfile
);
940 g_test_bug ("316309");
942 keyfile
= load_data (data
, 0);
944 check_string_value (keyfile
, "1", "key1", "123");
945 check_string_value (keyfile
, "2", "key2", "123");
947 g_key_file_free (keyfile
);
951 test_group_names (void)
954 GError
*error
= NULL
;
958 /* [ in group name */
961 keyfile
= g_key_file_new ();
962 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
963 g_key_file_free (keyfile
);
966 G_KEY_FILE_ERROR_PARSE
);
968 /* ] in group name */
971 keyfile
= g_key_file_new ();
972 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
973 g_key_file_free (keyfile
);
976 G_KEY_FILE_ERROR_PARSE
);
978 /* control char in group name */
981 keyfile
= g_key_file_new ();
982 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
983 g_key_file_free (keyfile
);
986 G_KEY_FILE_ERROR_PARSE
);
988 /* empty group name */
991 keyfile
= g_key_file_new ();
992 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
993 g_key_file_free (keyfile
);
996 G_KEY_FILE_ERROR_PARSE
);
998 /* Unicode in group name */
999 data
= "[\xc2\xbd]\n"
1001 keyfile
= g_key_file_new ();
1002 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1003 g_key_file_free (keyfile
);
1004 check_no_error (&error
);
1006 keyfile
= g_key_file_new ();
1007 /*g_key_file_set_string (keyfile, "a[b", "key1", "123");*/
1008 value
= g_key_file_get_string (keyfile
, "a[b", "key1", &error
);
1009 check_error (&error
,
1011 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1012 g_assert (value
== NULL
);
1013 g_key_file_free (keyfile
);
1015 keyfile
= g_key_file_new ();
1016 /*g_key_file_set_string (keyfile, "a]b", "key1", "123");*/
1017 value
= g_key_file_get_string (keyfile
, "a]b", "key1", &error
);
1018 check_error (&error
,
1020 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1021 g_assert (value
== NULL
);
1022 g_key_file_free (keyfile
);
1024 keyfile
= g_key_file_new ();
1025 /*g_key_file_set_string (keyfile, "a\tb", "key1", "123");*/
1026 value
= g_key_file_get_string (keyfile
, "a\tb", "key1", &error
);
1027 check_error (&error
,
1029 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1030 g_assert (value
== NULL
);
1031 g_key_file_free (keyfile
);
1033 keyfile
= g_key_file_new ();
1034 g_key_file_set_string (keyfile
, "\xc2\xbd", "key1", "123");
1035 check_string_value (keyfile
, "\xc2\xbd", "key1", "123");
1036 g_key_file_free (keyfile
);
1040 test_key_names (void)
1043 GError
*error
= NULL
;
1050 keyfile
= g_key_file_new ();
1051 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1052 g_key_file_free (keyfile
);
1053 check_error (&error
,
1055 G_KEY_FILE_ERROR_PARSE
);
1057 /* empty key name */
1060 keyfile
= g_key_file_new ();
1061 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1062 g_key_file_free (keyfile
);
1063 check_error (&error
,
1065 G_KEY_FILE_ERROR_PARSE
);
1067 /* empty key name */
1070 keyfile
= g_key_file_new ();
1071 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1072 g_key_file_free (keyfile
);
1073 check_error (&error
,
1075 G_KEY_FILE_ERROR_PARSE
);
1077 /* bad locale suffix */
1080 keyfile
= g_key_file_new ();
1081 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1082 g_key_file_free (keyfile
);
1083 check_error (&error
,
1085 G_KEY_FILE_ERROR_PARSE
);
1090 keyfile
= g_key_file_new ();
1091 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1092 check_no_error (&error
);
1093 check_string_value (keyfile
, "a", "foo", "123");
1094 g_key_file_free (keyfile
);
1099 keyfile
= g_key_file_new ();
1100 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1101 check_no_error (&error
);
1102 check_string_value (keyfile
, "a", "foo", "123");
1103 g_key_file_free (keyfile
);
1108 keyfile
= g_key_file_new ();
1109 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1110 check_no_error (&error
);
1111 check_string_value (keyfile
, "a", "foo bar", "123");
1112 g_key_file_free (keyfile
);
1117 keyfile
= g_key_file_new ();
1118 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1119 check_error (&error
,
1121 G_KEY_FILE_ERROR_PARSE
);
1122 g_key_file_free (keyfile
);
1124 /* control char in key name */
1127 keyfile
= g_key_file_new ();
1128 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1129 g_key_file_free (keyfile
);
1130 check_no_error (&error
);
1132 /* Unicode in key name */
1135 keyfile
= g_key_file_new ();
1136 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1137 g_key_file_free (keyfile
);
1138 check_no_error (&error
);
1140 keyfile
= g_key_file_new ();
1141 g_key_file_set_string (keyfile
, "a", "x", "123");
1142 /*g_key_file_set_string (keyfile, "a", "key=", "123");*/
1143 value
= g_key_file_get_string (keyfile
, "a", "key=", &error
);
1144 check_error (&error
,
1146 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1147 g_key_file_free (keyfile
);
1149 keyfile
= g_key_file_new ();
1150 g_key_file_set_string (keyfile
, "a", "x", "123");
1151 /*g_key_file_set_string (keyfile, "a", "key[", "123");*/
1152 value
= g_key_file_get_string (keyfile
, "a", "key[", &error
);
1153 check_error (&error
,
1155 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1156 g_key_file_free (keyfile
);
1158 keyfile
= g_key_file_new ();
1159 g_key_file_set_string (keyfile
, "a", "x", "123");
1160 g_key_file_set_string (keyfile
, "a", "key\tfoo", "123");
1161 value
= g_key_file_get_string (keyfile
, "a", "key\tfoo", &error
);
1162 check_no_error (&error
);
1164 g_key_file_free (keyfile
);
1166 keyfile
= g_key_file_new ();
1167 g_key_file_set_string (keyfile
, "a", "x", "123");
1168 /*g_key_file_set_string (keyfile, "a", " key", "123");*/
1169 value
= g_key_file_get_string (keyfile
, "a", " key", &error
);
1170 check_error (&error
,
1172 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1173 g_key_file_free (keyfile
);
1175 keyfile
= g_key_file_new ();
1176 g_key_file_set_string (keyfile
, "a", "x", "123");
1179 g_key_file_set_string (keyfile
, "a", "\xc2\xbd", "123");
1180 check_string_value (keyfile
, "a", "\xc2\xbd", "123");
1182 /* Keys with / + . (as used by the gnome-vfs mime cache) */
1183 g_key_file_set_string (keyfile
, "a", "foo/bar", "/");
1184 check_string_value (keyfile
, "a", "foo/bar", "/");
1185 g_key_file_set_string (keyfile
, "a", "foo+bar", "+");
1186 check_string_value (keyfile
, "a", "foo+bar", "+");
1187 g_key_file_set_string (keyfile
, "a", "foo.bar", ".");
1188 check_string_value (keyfile
, "a", "foo.bar", ".");
1190 g_key_file_free (keyfile
);
1194 test_duplicate_keys (void)
1202 keyfile
= load_data (data
, 0);
1203 check_string_value (keyfile
, "1", "key1", "345");
1205 g_key_file_free (keyfile
);
1209 test_duplicate_groups (void)
1218 g_test_bug ("157877");
1220 keyfile
= load_data (data
, 0);
1221 check_string_value (keyfile
, "Desktop Entry", "key1", "123");
1222 check_string_value (keyfile
, "Desktop Entry", "key2", "123");
1224 g_key_file_free (keyfile
);
1228 test_duplicate_groups2 (void)
1239 g_test_bug ("385910");
1241 keyfile
= load_data (data
, 0);
1242 check_string_value (keyfile
, "A", "foo", "bang");
1243 check_string_value (keyfile
, "B", "foo", "baz");
1245 g_key_file_free (keyfile
);
1249 test_reload_idempotency (void)
1251 static const gchar
*original_data
=""
1257 "# A random comment in the first group\n"
1258 "anotherkey=anothervalue\n"
1259 "# Second comment - one line\n"
1261 "# Third comment - two lines\n"
1262 "# Third comment - two lines\n"
1271 GError
*error
= NULL
;
1272 gchar
*data1
, *data2
;
1275 g_test_bug ("420686");
1277 /* check that we only insert a single new line between groups */
1278 keyfile
= g_key_file_new ();
1279 g_key_file_load_from_data (keyfile
,
1280 original_data
, strlen(original_data
),
1281 G_KEY_FILE_KEEP_COMMENTS
,
1283 check_no_error (&error
);
1285 data1
= g_key_file_to_data (keyfile
, &len1
, &error
);
1286 g_assert (data1
!= NULL
);
1287 g_key_file_free (keyfile
);
1289 keyfile
= g_key_file_new ();
1290 g_key_file_load_from_data (keyfile
,
1292 G_KEY_FILE_KEEP_COMMENTS
,
1294 check_no_error (&error
);
1296 data2
= g_key_file_to_data (keyfile
, &len2
, &error
);
1297 g_assert (data2
!= NULL
);
1298 g_key_file_free (keyfile
);
1300 g_assert_cmpstr (data1
, ==, data2
);
1306 static const char int64_data
[] =
1310 "c=123456789123456789\n"
1311 "d=-123456789123456789\n";
1322 g_test_bug ("614864");
1324 file
= g_key_file_new ();
1326 ok
= g_key_file_load_from_data (file
, int64_data
, strlen (int64_data
),
1330 c
= g_key_file_get_uint64 (file
, "bees", "c", NULL
);
1331 g_assert (c
== G_GUINT64_CONSTANT (123456789123456789));
1333 d
= g_key_file_get_int64 (file
, "bees", "d", NULL
);
1334 g_assert (d
== G_GINT64_CONSTANT (-123456789123456789));
1336 g_key_file_set_uint64 (file
, "bees", "c",
1337 G_GUINT64_CONSTANT (987654321987654321));
1338 value
= g_key_file_get_value (file
, "bees", "c", NULL
);
1339 g_assert_cmpstr (value
, ==, "987654321987654321");
1342 g_key_file_set_int64 (file
, "bees", "d",
1343 G_GINT64_CONSTANT (-987654321987654321));
1344 value
= g_key_file_get_value (file
, "bees", "d", NULL
);
1345 g_assert_cmpstr (value
, ==, "-987654321987654321");
1348 g_key_file_free (file
);
1356 gboolean bools
[2] = { TRUE
, FALSE
};
1359 file
= g_key_file_new ();
1362 /* Uses the value of $XDG_DATA_HOME we set in main() */
1363 loaded
= g_key_file_load_from_data_dirs (file
, "keyfiletest.ini", NULL
, 0, &error
);
1365 loaded
= g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "keyfiletest.ini", NULL
), 0, &error
);
1367 g_assert_no_error (error
);
1370 g_key_file_set_locale_string (file
, "test", "key4", "de", "Vierter Schlüssel");
1371 g_key_file_set_boolean_list (file
, "test", "key5", bools
, 2);
1372 g_key_file_set_integer (file
, "test", "key6", 22);
1373 g_key_file_set_double (file
, "test", "key7", 2.5);
1374 g_key_file_set_comment (file
, "test", "key7", "some float", NULL
);
1375 g_key_file_set_comment (file
, "test", NULL
, "the test group", NULL
);
1376 g_key_file_set_comment (file
, NULL
, NULL
, "top comment", NULL
);
1378 g_key_file_free (file
);
1380 file
= g_key_file_new ();
1382 g_assert (!g_key_file_load_from_data_dirs (file
, "keyfile-test.ini", NULL
, 0, &error
));
1383 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_NOT_FOUND
);
1384 g_error_free (error
);
1385 g_key_file_free (file
);
1393 static const char data
[] =
1397 "c=123456789123456789\n"
1398 "d=-123456789123456789\n";
1402 GError
*error
= NULL
;
1405 kf
= g_key_file_new ();
1406 ok
= g_key_file_load_from_data (kf
, data
, strlen (data
), 0, NULL
);
1409 file
= g_strdup ("key_file_XXXXXX");
1410 fd
= g_mkstemp (file
);
1411 g_assert (fd
!= -1);
1412 ok
= g_close (fd
, &error
);
1414 g_assert_no_error (error
);
1415 ok
= g_key_file_save_to_file (kf
, file
, &error
);
1417 g_assert_no_error (error
);
1419 kf2
= g_key_file_new ();
1420 ok
= g_key_file_load_from_file (kf2
, file
, 0, &error
);
1422 g_assert_no_error (error
);
1424 c
= g_key_file_get_uint64 (kf2
, "bees", "c", NULL
);
1425 g_assert (c
== G_GUINT64_CONSTANT (123456789123456789));
1429 g_key_file_free (kf
);
1430 g_key_file_free (kf2
);
1434 test_load_fail (void)
1439 file
= g_key_file_new ();
1441 g_assert (!g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "keyfile.c", NULL
), 0, &error
));
1442 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_PARSE
);
1443 g_clear_error (&error
);
1444 g_assert (!g_key_file_load_from_file (file
, "/nosuchfile", 0, &error
));
1445 g_assert_error (error
, G_FILE_ERROR
, G_FILE_ERROR_NOENT
);
1446 g_clear_error (&error
);
1448 g_key_file_free (file
);
1452 test_non_utf8 (void)
1455 static const char data
[] =
1458 "b=a;b;\230\230\230;\n"
1465 file
= g_key_file_new ();
1467 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, NULL
);
1471 s
= g_key_file_get_string (file
, "group", "a", &error
);
1472 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1473 g_assert (s
== NULL
);
1475 g_clear_error (&error
);
1476 l
= g_key_file_get_string_list (file
, "group", "b", NULL
, &error
);
1477 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1478 g_assert (l
== NULL
);
1480 g_clear_error (&error
);
1481 l
= g_key_file_get_string_list (file
, "group", "c", NULL
, &error
);
1482 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
1483 g_assert (l
== NULL
);
1485 g_clear_error (&error
);
1487 g_key_file_free (file
);
1491 test_page_boundary (void)
1497 #define GROUP "main_section"
1498 #define KEY_PREFIX "fill_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw_"
1499 #define FIRST_KEY 10
1503 g_test_bug ("640695");
1505 file
= g_key_file_new ();
1508 g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "pages.ini", NULL
), G_KEY_FILE_NONE
, &error
);
1509 g_assert_no_error (error
);
1511 for (i
= FIRST_KEY
; i
<= LAST_KEY
; i
++)
1516 key
= g_strdup_printf (KEY_PREFIX
"%d", i
);
1517 val
= g_key_file_get_integer (file
, GROUP
, key
, &error
);
1519 g_assert_no_error (error
);
1520 g_assert_cmpint (val
, ==, VALUE
);
1523 g_key_file_free (file
);
1530 static const char data
[] =
1535 file
= g_key_file_new ();
1537 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, NULL
);
1539 g_assert (g_key_file_has_key (file
, "group", "a", NULL
));
1540 g_key_file_ref (file
);
1541 g_key_file_free (file
);
1542 g_key_file_unref (file
);
1545 /* https://bugzilla.gnome.org/show_bug.cgi?id=634232 */
1547 test_replace_value (void)
1551 keyfile
= g_key_file_new();
1552 g_key_file_set_value(keyfile
, "grupo1", "chave1", "1234567890");
1553 g_key_file_set_value(keyfile
, "grupo1", "chave1", "123123423423423432432423423");
1554 g_key_file_remove_group(keyfile
, "grupo1", NULL
);
1555 g_free (g_key_file_to_data (keyfile
, NULL
, NULL
));
1556 g_key_file_unref (keyfile
);
1560 test_list_separator (void)
1563 GError
*error
= NULL
;
1569 keyfile
= g_key_file_new ();
1570 g_key_file_set_list_separator (keyfile
, ',');
1571 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1573 check_string_list_value (keyfile
, "test", "key1", "v1", "v2", NULL
);
1574 g_key_file_unref (keyfile
);
1578 test_empty_string (void)
1580 GError
*error
= NULL
;
1583 kf
= g_key_file_new ();
1585 g_key_file_load_from_data (kf
, "", 0, 0, &error
);
1586 g_assert_no_error (error
);
1588 g_key_file_load_from_data (kf
, "", -1, 0, &error
);
1589 g_assert_no_error (error
);
1591 /* NULL is a fine pointer to use if length is zero */
1592 g_key_file_load_from_data (kf
, NULL
, 0, 0, &error
);
1593 g_assert_no_error (error
);
1595 /* should not attempt to access non-NULL pointer if length is zero */
1596 g_key_file_load_from_data (kf
, GINT_TO_POINTER (1), 0, 0, &error
);
1597 g_assert_no_error (error
);
1599 g_key_file_unref (kf
);
1606 static const char data
[] =
1613 file
= g_key_file_new ();
1616 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, &error
);
1618 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1619 g_clear_error (&error
);
1620 g_key_file_free (file
);
1627 static const char data
[] =
1629 "Encoding=non-UTF-8\n";
1633 file
= g_key_file_new ();
1636 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, &error
);
1638 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1639 g_clear_error (&error
);
1640 g_key_file_free (file
);
1644 test_roundtrip (void)
1647 const gchar orig
[] =
1656 kf
= load_data (orig
, G_KEY_FILE_KEEP_COMMENTS
);
1657 g_key_file_set_integer (kf
, "Group1", "key2", 0);
1658 g_key_file_remove_key (kf
, "Group1", "key2", NULL
);
1660 data
= g_key_file_to_data (kf
, &len
, NULL
);
1661 g_assert_cmpstr (data
, ==, orig
);
1664 g_key_file_free (kf
);
1670 const gchar data
[] =
1677 GKeyFile
*kf
= g_key_file_new ();
1678 GBytes
*bytes
= g_bytes_new (data
, strlen (data
));
1679 GError
*error
= NULL
;
1684 g_key_file_load_from_bytes (kf
, bytes
, 0, &error
);
1686 g_assert_no_error (error
);
1688 names
= g_key_file_get_groups (kf
, &len
);
1689 g_assert_nonnull (names
);
1691 check_length ("groups", g_strv_length (names
), len
, 2);
1692 check_name ("group name", names
[0], "Group1", 0);
1693 check_name ("group name", names
[1], "Group2", 1);
1695 check_string_value (kf
, "Group1", "key1", "value1");
1696 check_string_value (kf
, "Group2", "key2", "value2");
1699 g_bytes_unref (bytes
);
1700 g_key_file_free (kf
);
1704 test_get_locale (void)
1708 kf
= g_key_file_new ();
1709 g_key_file_load_from_data (kf
,
1714 -1, G_KEY_FILE_KEEP_TRANSLATIONS
,
1717 check_locale_string_value (kf
, "Group", "x", "fr_CA", "a");
1718 check_string_locale_value (kf
, "Group", "x", "fr_CA", "fr_CA");
1720 check_locale_string_value (kf
, "Group", "x", "fr_CH", "b");
1721 check_string_locale_value (kf
, "Group", "x", "fr_CH", "fr");
1723 check_locale_string_value (kf
, "Group", "x", "eo", "c");
1724 check_string_locale_value (kf
, "Group", "x", "eo", NULL
);
1726 g_key_file_free (kf
);
1730 main (int argc
, char *argv
[])
1732 g_test_init (&argc
, &argv
, NULL
);
1735 g_setenv ("XDG_DATA_HOME", g_test_get_dir (G_TEST_DIST
), TRUE
);
1738 g_test_bug_base ("http://bugzilla.gnome.org/");
1740 g_test_add_func ("/keyfile/line-ends", test_line_ends
);
1741 g_test_add_func ("/keyfile/whitespace", test_whitespace
);
1742 g_test_add_func ("/keyfile/comments", test_comments
);
1743 g_test_add_func ("/keyfile/listing", test_listing
);
1744 g_test_add_func ("/keyfile/string", test_string
);
1745 g_test_add_func ("/keyfile/boolean", test_boolean
);
1746 g_test_add_func ("/keyfile/number", test_number
);
1747 g_test_add_func ("/keyfile/locale-string", test_locale_string
);
1748 g_test_add_func ("/keyfile/lists", test_lists
);
1749 g_test_add_func ("/keyfile/lists-set-get", test_lists_set_get
);
1750 g_test_add_func ("/keyfile/group-remove", test_group_remove
);
1751 g_test_add_func ("/keyfile/key-remove", test_key_remove
);
1752 g_test_add_func ("/keyfile/groups", test_groups
);
1753 g_test_add_func ("/keyfile/duplicate-keys", test_duplicate_keys
);
1754 g_test_add_func ("/keyfile/duplicate-groups", test_duplicate_groups
);
1755 g_test_add_func ("/keyfile/duplicate-groups2", test_duplicate_groups2
);
1756 g_test_add_func ("/keyfile/group-names", test_group_names
);
1757 g_test_add_func ("/keyfile/key-names", test_key_names
);
1758 g_test_add_func ("/keyfile/reload", test_reload_idempotency
);
1759 g_test_add_func ("/keyfile/int64", test_int64
);
1760 g_test_add_func ("/keyfile/load", test_load
);
1761 g_test_add_func ("/keyfile/save", test_save
);
1762 g_test_add_func ("/keyfile/load-fail", test_load_fail
);
1763 g_test_add_func ("/keyfile/non-utf8", test_non_utf8
);
1764 g_test_add_func ("/keyfile/page-boundary", test_page_boundary
);
1765 g_test_add_func ("/keyfile/ref", test_ref
);
1766 g_test_add_func ("/keyfile/replace-value", test_replace_value
);
1767 g_test_add_func ("/keyfile/list-separator", test_list_separator
);
1768 g_test_add_func ("/keyfile/empty-string", test_empty_string
);
1769 g_test_add_func ("/keyfile/limbo", test_limbo
);
1770 g_test_add_func ("/keyfile/utf8", test_utf8
);
1771 g_test_add_func ("/keyfile/roundtrip", test_roundtrip
);
1772 g_test_add_func ("/keyfile/bytes", test_bytes
);
1773 g_test_add_func ("/keyfile/get-locale", test_get_locale
);
1775 return g_test_run ();