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_list_value (GKeyFile
*keyfile
,
82 value
= g_key_file_get_string_list (keyfile
, group
, key
, &len
, &error
);
83 check_no_error (&error
);
84 g_assert (value
!= NULL
);
88 v
= va_arg (args
, gchar
*);
91 g_assert (value
[i
] != NULL
);
92 g_assert_cmpstr (v
, ==, value
[i
]);
94 v
= va_arg (args
, gchar
*);
103 check_locale_string_list_value (GKeyFile
*keyfile
,
113 GError
*error
= NULL
;
115 value
= g_key_file_get_locale_string_list (keyfile
, group
, key
, locale
, &len
, &error
);
116 check_no_error (&error
);
117 g_assert (value
!= NULL
);
119 va_start (args
, locale
);
121 v
= va_arg (args
, gchar
*);
124 g_assert (value
[i
] != NULL
);
125 g_assert_cmpstr (v
, ==, value
[i
]);
127 v
= va_arg (args
, gchar
*);
136 check_integer_list_value (GKeyFile
*keyfile
,
145 GError
*error
= NULL
;
147 value
= g_key_file_get_integer_list (keyfile
, group
, key
, &len
, &error
);
148 check_no_error (&error
);
149 g_assert (value
!= NULL
);
151 va_start (args
, key
);
153 v
= va_arg (args
, gint
);
156 g_assert_cmpint (i
, <, len
);
157 g_assert_cmpint (value
[i
], ==, v
);
159 v
= va_arg (args
, gint
);
168 check_double_list_value (GKeyFile
*keyfile
,
177 GError
*error
= NULL
;
179 value
= g_key_file_get_double_list (keyfile
, group
, key
, &len
, &error
);
180 check_no_error (&error
);
181 g_assert (value
!= NULL
);
183 va_start (args
, key
);
185 v
= va_arg (args
, gdouble
);
188 g_assert_cmpint (i
, <, len
);
189 g_assert_cmpfloat (value
[i
], ==, v
);
191 v
= va_arg (args
, gdouble
);
200 check_boolean_list_value (GKeyFile
*keyfile
,
209 GError
*error
= NULL
;
211 value
= g_key_file_get_boolean_list (keyfile
, group
, key
, &len
, &error
);
212 check_no_error (&error
);
213 g_assert (value
!= NULL
);
215 va_start (args
, key
);
217 v
= va_arg (args
, gboolean
);
220 g_assert_cmpint (i
, <, len
);
221 g_assert_cmpint (value
[i
], ==, v
);
223 v
= va_arg (args
, gboolean
);
232 check_boolean_value (GKeyFile
*keyfile
,
237 GError
*error
= NULL
;
240 value
= g_key_file_get_boolean (keyfile
, group
, key
, &error
);
241 check_no_error (&error
);
242 g_assert_cmpint (value
, ==, expected
);
246 check_integer_value (GKeyFile
*keyfile
,
251 GError
*error
= NULL
;
254 value
= g_key_file_get_integer (keyfile
, group
, key
, &error
);
255 check_no_error (&error
);
256 g_assert_cmpint (value
, ==, expected
);
260 check_double_value (GKeyFile
*keyfile
,
265 GError
*error
= NULL
;
268 value
= g_key_file_get_double (keyfile
, group
, key
, &error
);
269 check_no_error (&error
);
270 g_assert_cmpfloat (value
, ==, expected
);
274 check_name (const gchar
*what
,
276 const gchar
*expected
,
279 g_assert_cmpstr (value
, ==, expected
);
283 check_length (const gchar
*what
,
288 g_assert_cmpint (n_items
, ==, length
);
289 g_assert_cmpint (n_items
, ==, expected
);
293 /* check that both \n and \r\n are accepted as line ends,
294 * and that stray \r are passed through
297 test_line_ends (void)
309 keyfile
= load_data (data
, 0);
311 check_string_value (keyfile
, "group1", "key1", "value1");
312 check_string_value (keyfile
, "group1", "key2", "value2");
313 check_string_value (keyfile
, "group2", "key3", "value3\r");
314 check_string_value (keyfile
, "group2", "key4", "value4");
316 g_key_file_free (keyfile
);
319 /* check handling of whitespace
322 test_whitespace (void)
335 keyfile
= load_data (data
, 0);
337 check_string_value (keyfile
, "group1", "key1", "value1");
338 check_string_value (keyfile
, "group1", "key2", "value2");
339 check_string_value (keyfile
, " group2 ", "key3", "value3 ");
340 check_string_value (keyfile
, " group2 ", "key4", "value \t4");
341 check_string_value (keyfile
, " group2 ", "key5", "value5");
343 g_key_file_free (keyfile
);
346 /* check handling of comments
354 GError
*error
= NULL
;
359 "# top comment, continued\n"
363 "# key comment, continued\n"
365 "# line end check\r\n"
369 "# group comment, continued\n"
372 const gchar
*top_comment
= " top comment\n top comment, continued\n";
373 const gchar
*group_comment
= " group comment\n group comment, continued\n";
374 const gchar
*key_comment
= " key comment\n key comment, continued\n";
376 keyfile
= load_data (data
, 0);
378 check_string_value (keyfile
, "group1", "key1", "value1");
379 check_string_value (keyfile
, "group1", "key2", "value2");
380 check_string_value (keyfile
, "group1", "key3", "value3");
381 check_string_value (keyfile
, "group1", "key4", "value4");
383 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
384 check_no_error (&error
);
386 check_length ("keys", g_strv_length (names
), len
, 4);
387 check_name ("key", names
[0], "key1", 0);
388 check_name ("key", names
[1], "key2", 1);
389 check_name ("key", names
[2], "key3", 2);
390 check_name ("key", names
[3], "key4", 3);
394 g_key_file_free (keyfile
);
396 keyfile
= load_data (data
, G_KEY_FILE_KEEP_COMMENTS
);
398 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
399 check_no_error (&error
);
401 check_length ("keys", g_strv_length (names
), len
, 4);
402 check_name ("key", names
[0], "key1", 0);
403 check_name ("key", names
[1], "key2", 1);
404 check_name ("key", names
[2], "key3", 2);
405 check_name ("key", names
[3], "key4", 3);
409 comment
= g_key_file_get_comment (keyfile
, NULL
, NULL
, &error
);
410 check_no_error (&error
);
411 check_name ("top comment", comment
, top_comment
, 0);
414 comment
= g_key_file_get_comment (keyfile
, "group1", "key2", &error
);
415 check_no_error (&error
);
416 check_name ("key comment", comment
, key_comment
, 0);
419 g_key_file_remove_comment (keyfile
, "group1", "key2", &error
);
420 check_no_error (&error
);
421 comment
= g_key_file_get_comment (keyfile
, "group1", "key2", &error
);
422 check_no_error (&error
);
423 g_assert (comment
== NULL
);
425 comment
= g_key_file_get_comment (keyfile
, "group2", NULL
, &error
);
426 check_no_error (&error
);
427 check_name ("group comment", comment
, group_comment
, 0);
430 comment
= g_key_file_get_comment (keyfile
, "group3", NULL
, &error
);
433 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
434 g_assert (comment
== NULL
);
436 g_key_file_free (keyfile
);
440 /* check key and group listing */
448 GError
*error
= NULL
;
458 keyfile
= load_data (data
, 0);
460 names
= g_key_file_get_groups (keyfile
, &len
);
461 g_assert (names
!= NULL
);
463 check_length ("groups", g_strv_length (names
), len
, 2);
464 check_name ("group name", names
[0], "group1", 0);
465 check_name ("group name", names
[1], "group2", 1);
469 names
= g_key_file_get_keys (keyfile
, "group1", &len
, &error
);
470 check_no_error (&error
);
472 check_length ("keys", g_strv_length (names
), len
, 2);
473 check_name ("key", names
[0], "key1", 0);
474 check_name ("key", names
[1], "key2", 1);
478 names
= g_key_file_get_keys (keyfile
, "no-such-group", &len
, &error
);
479 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
483 g_assert (g_key_file_has_group (keyfile
, "group1"));
484 g_assert (g_key_file_has_group (keyfile
, "group2"));
485 g_assert (!g_key_file_has_group (keyfile
, "group10"));
486 g_assert (!g_key_file_has_group (keyfile
, "group20"));
488 start
= g_key_file_get_start_group (keyfile
);
489 g_assert_cmpstr (start
, ==, "group1");
492 g_assert (g_key_file_has_key (keyfile
, "group1", "key1", &error
));
493 check_no_error (&error
);
494 g_assert (g_key_file_has_key (keyfile
, "group2", "key3", &error
));
495 check_no_error (&error
);
496 g_assert (!g_key_file_has_key (keyfile
, "group2", "no-such-key", NULL
));
498 g_key_file_has_key (keyfile
, "no-such-group", "key", &error
);
499 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
501 g_key_file_free (keyfile
);
504 /* check parsing of string values */
509 GError
*error
= NULL
;
511 const gchar
* const list
[3] = {
518 "key1=\\s\\n\\t\\r\\\\\n"
521 "key4=\xe2\x89\xa0\xe2\x89\xa0\n"
522 "key5= leading space\n"
523 "key6=trailing space \n"
525 "key1=\\a\\b\\0800xff\n"
528 keyfile
= load_data (data
, 0);
530 check_string_value (keyfile
, "valid", "key1", " \n\t\r\\");
531 check_string_value (keyfile
, "valid", "key2", "\"quoted\"");
532 check_string_value (keyfile
, "valid", "key3", "'quoted'");
533 check_string_value (keyfile
, "valid", "key4", "\xe2\x89\xa0\xe2\x89\xa0");
534 check_string_value (keyfile
, "valid", "key5", "leading space");
535 check_string_value (keyfile
, "valid", "key6", "trailing space ");
537 value
= g_key_file_get_string (keyfile
, "invalid", "key1", &error
);
538 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
541 value
= g_key_file_get_string (keyfile
, "invalid", "key2", &error
);
542 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
545 g_key_file_set_string (keyfile
, "inserted", "key1", "simple");
546 g_key_file_set_string (keyfile
, "inserted", "key2", " leading space");
547 g_key_file_set_string (keyfile
, "inserted", "key3", "\tleading tab");
548 g_key_file_set_string (keyfile
, "inserted", "key4", "new\nline");
549 g_key_file_set_string (keyfile
, "inserted", "key5", "carriage\rreturn");
550 g_key_file_set_string (keyfile
, "inserted", "key6", "slash\\yay!");
551 g_key_file_set_string_list (keyfile
, "inserted", "key7", list
, 3);
553 check_string_value (keyfile
, "inserted", "key1", "simple");
554 check_string_value (keyfile
, "inserted", "key2", " leading space");
555 check_string_value (keyfile
, "inserted", "key3", "\tleading tab");
556 check_string_value (keyfile
, "inserted", "key4", "new\nline");
557 check_string_value (keyfile
, "inserted", "key5", "carriage\rreturn");
558 check_string_value (keyfile
, "inserted", "key6", "slash\\yay!");
559 check_string_list_value (keyfile
, "inserted", "key7", "one", "two;andahalf", "3", NULL
);
561 g_key_file_free (keyfile
);
564 /* check parsing of boolean values */
569 GError
*error
= NULL
;
585 keyfile
= load_data (data
, 0);
587 check_boolean_value (keyfile
, "valid", "key1", TRUE
);
588 check_boolean_value (keyfile
, "valid", "key2", FALSE
);
589 check_boolean_value (keyfile
, "valid", "key3", TRUE
);
590 check_boolean_value (keyfile
, "valid", "key4", FALSE
);
591 check_boolean_value (keyfile
, "valid", "key5", TRUE
);
592 check_boolean_value (keyfile
, "valid", "key6", TRUE
);
594 g_key_file_get_boolean (keyfile
, "invalid", "key1", &error
);
595 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
597 g_key_file_get_boolean (keyfile
, "invalid", "key2", &error
);
598 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
600 g_key_file_get_boolean (keyfile
, "invalid", "key3", &error
);
601 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
603 g_key_file_get_boolean (keyfile
, "invalid", "key4", &error
);
604 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
606 g_key_file_set_boolean (keyfile
, "valid", "key1", FALSE
);
607 check_boolean_value (keyfile
, "valid", "key1", FALSE
);
609 g_key_file_free (keyfile
);
612 /* check parsing of integer and double values */
617 GError
*error
= NULL
;
643 keyfile
= load_data (data
, 0);
645 check_integer_value (keyfile
, "valid", "key1", 0);
646 check_integer_value (keyfile
, "valid", "key2", 1);
647 check_integer_value (keyfile
, "valid", "key3", -1);
648 check_integer_value (keyfile
, "valid", "key4", 2324431);
649 check_integer_value (keyfile
, "valid", "key5", -2324431);
650 check_integer_value (keyfile
, "valid", "key6", 111);
651 check_integer_value (keyfile
, "valid", "key7", 1);
652 check_integer_value (keyfile
, "valid", "key8", 1);
653 check_double_value (keyfile
, "valid", "dkey1", 111.0);
654 check_double_value (keyfile
, "valid", "dkey2", 145.45);
655 check_double_value (keyfile
, "valid", "dkey3", -3453.7);
657 g_key_file_get_integer (keyfile
, "invalid", "key1", &error
);
658 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
660 g_key_file_get_integer (keyfile
, "invalid", "key2", &error
);
661 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
663 g_key_file_get_integer (keyfile
, "invalid", "key3", &error
);
664 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
666 g_key_file_get_integer (keyfile
, "invalid", "key4", &error
);
667 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
669 dval
= g_key_file_get_double (keyfile
, "invalid", "key5", &error
);
670 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
671 g_assert_cmpfloat (dval
, ==, 0.0);
673 dval
= g_key_file_get_double (keyfile
, "invalid", "key6", &error
);
674 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
675 g_assert_cmpfloat (dval
, ==, 0.0);
677 dval
= g_key_file_get_double (keyfile
, "invalid", "key7", &error
);
678 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
679 g_assert_cmpfloat (dval
, ==, 0.0);
681 dval
= g_key_file_get_double (keyfile
, "invalid", "key8", &error
);
682 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
683 g_assert_cmpfloat (dval
, ==, 0.0);
685 g_key_file_free (keyfile
);
688 /* check handling of translated strings */
690 test_locale_string (void)
699 "key1[de_DE]=v1-de_DE\n"
700 "key1[de_DE.UTF8]=v1-de_DE.UTF8\n"
703 "key1[sr@Latn]=v1-sr\n";
705 keyfile
= load_data (data
, G_KEY_FILE_KEEP_TRANSLATIONS
);
707 check_locale_string_value (keyfile
, "valid", "key1", "it", "v1");
708 check_locale_string_value (keyfile
, "valid", "key1", "de", "v1-de");
709 check_locale_string_value (keyfile
, "valid", "key1", "de_DE", "v1-de_DE");
710 check_locale_string_value (keyfile
, "valid", "key1", "de_DE.UTF8", "v1-de_DE.UTF8");
711 check_locale_string_value (keyfile
, "valid", "key1", "fr", "v1-fr");
712 check_locale_string_value (keyfile
, "valid", "key1", "fr_FR", "v1-fr");
713 check_locale_string_value (keyfile
, "valid", "key1", "en", "v1-en");
714 check_locale_string_value (keyfile
, "valid", "key1", "sr@Latn", "v1-sr");
716 g_key_file_free (keyfile
);
718 /* now test that translations are thrown away */
720 old_locale
= g_strdup (setlocale (LC_ALL
, NULL
));
721 g_setenv ("LANGUAGE", "de", TRUE
);
722 setlocale (LC_ALL
, "");
724 keyfile
= load_data (data
, 0);
726 check_locale_string_value (keyfile
, "valid", "key1", "it", "v1");
727 check_locale_string_value (keyfile
, "valid", "key1", "de", "v1-de");
728 check_locale_string_value (keyfile
, "valid", "key1", "de_DE", "v1-de");
729 check_locale_string_value (keyfile
, "valid", "key1", "de_DE.UTF8", "v1-de");
730 check_locale_string_value (keyfile
, "valid", "key1", "fr", "v1");
731 check_locale_string_value (keyfile
, "valid", "key1", "fr_FR", "v1");
732 check_locale_string_value (keyfile
, "valid", "key1", "en", "v1");
734 g_key_file_free (keyfile
);
736 setlocale (LC_ALL
, old_locale
);
753 "key7= 1 ; 0 ; -1 \n"
755 "key9=0;1.3456;-76532.456\n";
757 keyfile
= load_data (data
, 0);
759 check_string_list_value (keyfile
, "valid", "key1", "v1", "v2", NULL
);
760 check_string_list_value (keyfile
, "valid", "key2", "v1", "v2", NULL
);
761 check_string_list_value (keyfile
, "valid", "key3", "v1,v2", NULL
);
762 check_string_list_value (keyfile
, "valid", "key4", "v1;v2", NULL
);
763 check_boolean_list_value (keyfile
, "valid", "key5", TRUE
, FALSE
, -100);
764 check_integer_list_value (keyfile
, "valid", "key6", 1, 0, -1, -100);
765 check_double_list_value (keyfile
, "valid", "key9", 0.0, 1.3456, -76532.456, -100.0);
766 /* maybe these should be valid */
767 /* check_integer_list_value (keyfile, "valid", "key7", 1, 0, -1, -100);*/
768 /* check_string_list_value (keyfile, "valid", "key8", "v1\\,v2", NULL);*/
770 g_key_file_free (keyfile
);
772 /* Now check an alternate separator */
774 keyfile
= load_data (data
, 0);
775 g_key_file_set_list_separator (keyfile
, ',');
777 check_string_list_value (keyfile
, "valid", "key1", "v1;v2", NULL
);
778 check_string_list_value (keyfile
, "valid", "key2", "v1;v2;", NULL
);
779 check_string_list_value (keyfile
, "valid", "key3", "v1", "v2", NULL
);
781 g_key_file_free (keyfile
);
785 test_lists_set_get (void)
788 static const char * const strings
[] = { "v1", "v2" };
789 static const char * const locale_strings
[] = { "v1-l", "v2-l" };
790 static int integers
[] = { 1, -1, 2 };
791 static gdouble doubles
[] = { 3.14, 2.71 };
793 keyfile
= g_key_file_new ();
794 g_key_file_set_string_list (keyfile
, "group0", "key1", strings
, G_N_ELEMENTS (strings
));
795 g_key_file_set_locale_string_list (keyfile
, "group0", "key1", "de", locale_strings
, G_N_ELEMENTS (locale_strings
));
796 g_key_file_set_integer_list (keyfile
, "group0", "key2", integers
, G_N_ELEMENTS (integers
));
797 g_key_file_set_double_list (keyfile
, "group0", "key3", doubles
, G_N_ELEMENTS (doubles
));
799 check_string_list_value (keyfile
, "group0", "key1", strings
[0], strings
[1], NULL
);
800 check_locale_string_list_value (keyfile
, "group0", "key1", "de", locale_strings
[0], locale_strings
[1], NULL
);
801 check_integer_list_value (keyfile
, "group0", "key2", integers
[0], integers
[1], -100);
802 check_double_list_value (keyfile
, "group0", "key3", doubles
[0], doubles
[1], -100.0);
803 g_key_file_free (keyfile
);
805 /* and again with a different list separator */
806 keyfile
= g_key_file_new ();
807 g_key_file_set_list_separator (keyfile
, ',');
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
);
821 test_group_remove (void)
826 GError
*error
= NULL
;
837 g_test_bug ("165887");
839 keyfile
= load_data (data
, 0);
841 names
= g_key_file_get_groups (keyfile
, &len
);
842 g_assert (names
!= NULL
);
844 check_length ("groups", g_strv_length (names
), len
, 3);
845 check_name ("group name", names
[0], "group1", 0);
846 check_name ("group name", names
[1], "group2", 1);
847 check_name ("group name", names
[2], "group3", 2);
849 g_key_file_remove_group (keyfile
, "group1", &error
);
850 check_no_error (&error
);
854 names
= g_key_file_get_groups (keyfile
, &len
);
855 g_assert (names
!= NULL
);
857 check_length ("groups", g_strv_length (names
), len
, 2);
858 check_name ("group name", names
[0], "group2", 0);
859 check_name ("group name", names
[1], "group3", 1);
861 g_key_file_remove_group (keyfile
, "group2", &error
);
862 check_no_error (&error
);
866 names
= g_key_file_get_groups (keyfile
, &len
);
867 g_assert (names
!= NULL
);
869 check_length ("groups", g_strv_length (names
), len
, 1);
870 check_name ("group name", names
[0], "group3", 0);
872 g_key_file_remove_group (keyfile
, "no such group", &error
);
873 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
877 g_key_file_free (keyfile
);
881 test_key_remove (void)
885 GError
*error
= NULL
;
892 g_test_bug ("165980");
894 keyfile
= load_data (data
, 0);
896 check_string_value (keyfile
, "group1", "key1", "bla");
898 g_key_file_remove_key (keyfile
, "group1", "key1", &error
);
899 check_no_error (&error
);
901 value
= g_key_file_get_string (keyfile
, "group1", "key1", &error
);
902 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
905 g_key_file_remove_key (keyfile
, "group1", "key1", &error
);
906 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
908 g_key_file_remove_key (keyfile
, "no such group", "key1", &error
);
909 check_error (&error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
911 g_key_file_free (keyfile
);
926 g_test_bug ("316309");
928 keyfile
= load_data (data
, 0);
930 check_string_value (keyfile
, "1", "key1", "123");
931 check_string_value (keyfile
, "2", "key2", "123");
933 g_key_file_free (keyfile
);
937 test_group_names (void)
940 GError
*error
= NULL
;
944 /* [ in group name */
947 keyfile
= g_key_file_new ();
948 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
949 g_key_file_free (keyfile
);
952 G_KEY_FILE_ERROR_PARSE
);
954 /* ] in group name */
957 keyfile
= g_key_file_new ();
958 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
959 g_key_file_free (keyfile
);
962 G_KEY_FILE_ERROR_PARSE
);
964 /* control char in group name */
967 keyfile
= g_key_file_new ();
968 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
969 g_key_file_free (keyfile
);
972 G_KEY_FILE_ERROR_PARSE
);
974 /* empty group name */
977 keyfile
= g_key_file_new ();
978 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
979 g_key_file_free (keyfile
);
982 G_KEY_FILE_ERROR_PARSE
);
984 /* Unicode in group name */
985 data
= "[\xc2\xbd]\n"
987 keyfile
= g_key_file_new ();
988 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
989 g_key_file_free (keyfile
);
990 check_no_error (&error
);
992 keyfile
= g_key_file_new ();
993 /*g_key_file_set_string (keyfile, "a[b", "key1", "123");*/
994 value
= g_key_file_get_string (keyfile
, "a[b", "key1", &error
);
997 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
998 g_assert (value
== NULL
);
999 g_key_file_free (keyfile
);
1001 keyfile
= g_key_file_new ();
1002 /*g_key_file_set_string (keyfile, "a]b", "key1", "123");*/
1003 value
= g_key_file_get_string (keyfile
, "a]b", "key1", &error
);
1004 check_error (&error
,
1006 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1007 g_assert (value
== NULL
);
1008 g_key_file_free (keyfile
);
1010 keyfile
= g_key_file_new ();
1011 /*g_key_file_set_string (keyfile, "a\tb", "key1", "123");*/
1012 value
= g_key_file_get_string (keyfile
, "a\tb", "key1", &error
);
1013 check_error (&error
,
1015 G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1016 g_assert (value
== NULL
);
1017 g_key_file_free (keyfile
);
1019 keyfile
= g_key_file_new ();
1020 g_key_file_set_string (keyfile
, "\xc2\xbd", "key1", "123");
1021 check_string_value (keyfile
, "\xc2\xbd", "key1", "123");
1022 g_key_file_free (keyfile
);
1026 test_key_names (void)
1029 GError
*error
= NULL
;
1036 keyfile
= g_key_file_new ();
1037 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1038 g_key_file_free (keyfile
);
1039 check_error (&error
,
1041 G_KEY_FILE_ERROR_PARSE
);
1043 /* empty key name */
1046 keyfile
= g_key_file_new ();
1047 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1048 g_key_file_free (keyfile
);
1049 check_error (&error
,
1051 G_KEY_FILE_ERROR_PARSE
);
1053 /* empty key name */
1056 keyfile
= g_key_file_new ();
1057 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1058 g_key_file_free (keyfile
);
1059 check_error (&error
,
1061 G_KEY_FILE_ERROR_PARSE
);
1063 /* bad locale suffix */
1066 keyfile
= g_key_file_new ();
1067 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1068 g_key_file_free (keyfile
);
1069 check_error (&error
,
1071 G_KEY_FILE_ERROR_PARSE
);
1076 keyfile
= g_key_file_new ();
1077 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1078 check_no_error (&error
);
1079 check_string_value (keyfile
, "a", "foo", "123");
1080 g_key_file_free (keyfile
);
1085 keyfile
= g_key_file_new ();
1086 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1087 check_no_error (&error
);
1088 check_string_value (keyfile
, "a", "foo", "123");
1089 g_key_file_free (keyfile
);
1094 keyfile
= g_key_file_new ();
1095 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1096 check_no_error (&error
);
1097 check_string_value (keyfile
, "a", "foo bar", "123");
1098 g_key_file_free (keyfile
);
1103 keyfile
= g_key_file_new ();
1104 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1105 check_error (&error
,
1107 G_KEY_FILE_ERROR_PARSE
);
1108 g_key_file_free (keyfile
);
1110 /* control char in key name */
1113 keyfile
= g_key_file_new ();
1114 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1115 g_key_file_free (keyfile
);
1116 check_no_error (&error
);
1118 /* Unicode in key name */
1121 keyfile
= g_key_file_new ();
1122 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1123 g_key_file_free (keyfile
);
1124 check_no_error (&error
);
1126 keyfile
= g_key_file_new ();
1127 g_key_file_set_string (keyfile
, "a", "x", "123");
1128 /*g_key_file_set_string (keyfile, "a", "key=", "123");*/
1129 value
= g_key_file_get_string (keyfile
, "a", "key=", &error
);
1130 check_error (&error
,
1132 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1133 g_key_file_free (keyfile
);
1135 keyfile
= g_key_file_new ();
1136 g_key_file_set_string (keyfile
, "a", "x", "123");
1137 /*g_key_file_set_string (keyfile, "a", "key[", "123");*/
1138 value
= g_key_file_get_string (keyfile
, "a", "key[", &error
);
1139 check_error (&error
,
1141 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1142 g_key_file_free (keyfile
);
1144 keyfile
= g_key_file_new ();
1145 g_key_file_set_string (keyfile
, "a", "x", "123");
1146 g_key_file_set_string (keyfile
, "a", "key\tfoo", "123");
1147 value
= g_key_file_get_string (keyfile
, "a", "key\tfoo", &error
);
1148 check_no_error (&error
);
1150 g_key_file_free (keyfile
);
1152 keyfile
= g_key_file_new ();
1153 g_key_file_set_string (keyfile
, "a", "x", "123");
1154 /*g_key_file_set_string (keyfile, "a", " key", "123");*/
1155 value
= g_key_file_get_string (keyfile
, "a", " key", &error
);
1156 check_error (&error
,
1158 G_KEY_FILE_ERROR_KEY_NOT_FOUND
);
1159 g_key_file_free (keyfile
);
1161 keyfile
= g_key_file_new ();
1162 g_key_file_set_string (keyfile
, "a", "x", "123");
1165 g_key_file_set_string (keyfile
, "a", "\xc2\xbd", "123");
1166 check_string_value (keyfile
, "a", "\xc2\xbd", "123");
1168 /* Keys with / + . (as used by the gnome-vfs mime cache) */
1169 g_key_file_set_string (keyfile
, "a", "foo/bar", "/");
1170 check_string_value (keyfile
, "a", "foo/bar", "/");
1171 g_key_file_set_string (keyfile
, "a", "foo+bar", "+");
1172 check_string_value (keyfile
, "a", "foo+bar", "+");
1173 g_key_file_set_string (keyfile
, "a", "foo.bar", ".");
1174 check_string_value (keyfile
, "a", "foo.bar", ".");
1176 g_key_file_free (keyfile
);
1180 test_duplicate_keys (void)
1188 keyfile
= load_data (data
, 0);
1189 check_string_value (keyfile
, "1", "key1", "345");
1191 g_key_file_free (keyfile
);
1195 test_duplicate_groups (void)
1204 g_test_bug ("157877");
1206 keyfile
= load_data (data
, 0);
1207 check_string_value (keyfile
, "Desktop Entry", "key1", "123");
1208 check_string_value (keyfile
, "Desktop Entry", "key2", "123");
1210 g_key_file_free (keyfile
);
1214 test_duplicate_groups2 (void)
1225 g_test_bug ("385910");
1227 keyfile
= load_data (data
, 0);
1228 check_string_value (keyfile
, "A", "foo", "bang");
1229 check_string_value (keyfile
, "B", "foo", "baz");
1231 g_key_file_free (keyfile
);
1235 test_reload_idempotency (void)
1237 static const gchar
*original_data
=""
1243 "# A random comment in the first group\n"
1244 "anotherkey=anothervalue\n"
1245 "# Second comment - one line\n"
1247 "# Third comment - two lines\n"
1248 "# Third comment - two lines\n"
1257 GError
*error
= NULL
;
1258 gchar
*data1
, *data2
;
1261 g_test_bug ("420686");
1263 /* check that we only insert a single new line between groups */
1264 keyfile
= g_key_file_new ();
1265 g_key_file_load_from_data (keyfile
,
1266 original_data
, strlen(original_data
),
1267 G_KEY_FILE_KEEP_COMMENTS
,
1269 check_no_error (&error
);
1271 data1
= g_key_file_to_data (keyfile
, &len1
, &error
);
1272 g_assert (data1
!= NULL
);
1273 g_key_file_free (keyfile
);
1275 keyfile
= g_key_file_new ();
1276 g_key_file_load_from_data (keyfile
,
1278 G_KEY_FILE_KEEP_COMMENTS
,
1280 check_no_error (&error
);
1282 data2
= g_key_file_to_data (keyfile
, &len2
, &error
);
1283 g_assert (data2
!= NULL
);
1284 g_key_file_free (keyfile
);
1286 g_assert_cmpstr (data1
, ==, data2
);
1292 static const char int64_data
[] =
1296 "c=123456789123456789\n"
1297 "d=-123456789123456789\n";
1308 g_test_bug ("614864");
1310 file
= g_key_file_new ();
1312 ok
= g_key_file_load_from_data (file
, int64_data
, strlen (int64_data
),
1316 c
= g_key_file_get_uint64 (file
, "bees", "c", NULL
);
1317 g_assert (c
== G_GUINT64_CONSTANT (123456789123456789));
1319 d
= g_key_file_get_int64 (file
, "bees", "d", NULL
);
1320 g_assert (d
== G_GINT64_CONSTANT (-123456789123456789));
1322 g_key_file_set_uint64 (file
, "bees", "c",
1323 G_GUINT64_CONSTANT (987654321987654321));
1324 value
= g_key_file_get_value (file
, "bees", "c", NULL
);
1325 g_assert_cmpstr (value
, ==, "987654321987654321");
1328 g_key_file_set_int64 (file
, "bees", "d",
1329 G_GINT64_CONSTANT (-987654321987654321));
1330 value
= g_key_file_get_value (file
, "bees", "d", NULL
);
1331 g_assert_cmpstr (value
, ==, "-987654321987654321");
1334 g_key_file_free (file
);
1342 gboolean bools
[2] = { TRUE
, FALSE
};
1345 file
= g_key_file_new ();
1348 /* Uses the value of $XDG_DATA_HOME we set in main() */
1349 loaded
= g_key_file_load_from_data_dirs (file
, "keyfiletest.ini", NULL
, 0, &error
);
1351 loaded
= g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "keyfiletest.ini", NULL
), 0, &error
);
1353 g_assert_no_error (error
);
1356 g_key_file_set_locale_string (file
, "test", "key4", "de", "Vierter Schlüssel");
1357 g_key_file_set_boolean_list (file
, "test", "key5", bools
, 2);
1358 g_key_file_set_integer (file
, "test", "key6", 22);
1359 g_key_file_set_double (file
, "test", "key7", 2.5);
1360 g_key_file_set_comment (file
, "test", "key7", "some float", NULL
);
1361 g_key_file_set_comment (file
, "test", NULL
, "the test group", NULL
);
1362 g_key_file_set_comment (file
, NULL
, NULL
, "top comment", NULL
);
1364 g_key_file_free (file
);
1366 file
= g_key_file_new ();
1368 g_assert (!g_key_file_load_from_data_dirs (file
, "keyfile-test.ini", NULL
, 0, &error
));
1369 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_NOT_FOUND
);
1370 g_error_free (error
);
1371 g_key_file_free (file
);
1379 static const char data
[] =
1383 "c=123456789123456789\n"
1384 "d=-123456789123456789\n";
1388 GError
*error
= NULL
;
1391 kf
= g_key_file_new ();
1392 ok
= g_key_file_load_from_data (kf
, data
, strlen (data
), 0, NULL
);
1395 file
= g_strdup ("key_file_XXXXXX");
1396 fd
= g_mkstemp (file
);
1397 g_assert (fd
!= -1);
1398 ok
= g_close (fd
, &error
);
1400 g_assert_no_error (error
);
1401 ok
= g_key_file_save_to_file (kf
, file
, &error
);
1403 g_assert_no_error (error
);
1405 kf2
= g_key_file_new ();
1406 ok
= g_key_file_load_from_file (kf2
, file
, 0, &error
);
1408 g_assert_no_error (error
);
1410 c
= g_key_file_get_uint64 (kf2
, "bees", "c", NULL
);
1411 g_assert (c
== G_GUINT64_CONSTANT (123456789123456789));
1415 g_key_file_free (kf
);
1416 g_key_file_free (kf2
);
1420 test_load_fail (void)
1425 file
= g_key_file_new ();
1427 g_assert (!g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "keyfile.c", NULL
), 0, &error
));
1428 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_PARSE
);
1429 g_clear_error (&error
);
1430 g_assert (!g_key_file_load_from_file (file
, "/nosuchfile", 0, &error
));
1431 g_assert_error (error
, G_FILE_ERROR
, G_FILE_ERROR_NOENT
);
1432 g_clear_error (&error
);
1434 g_key_file_free (file
);
1438 test_non_utf8 (void)
1441 static const char data
[] =
1444 "b=a;b;\230\230\230;\n"
1451 file
= g_key_file_new ();
1453 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, NULL
);
1457 s
= g_key_file_get_string (file
, "group", "a", &error
);
1458 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1459 g_assert (s
== NULL
);
1461 g_clear_error (&error
);
1462 l
= g_key_file_get_string_list (file
, "group", "b", NULL
, &error
);
1463 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1464 g_assert (l
== NULL
);
1466 g_clear_error (&error
);
1467 l
= g_key_file_get_string_list (file
, "group", "c", NULL
, &error
);
1468 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_INVALID_VALUE
);
1469 g_assert (l
== NULL
);
1471 g_clear_error (&error
);
1473 g_key_file_free (file
);
1477 test_page_boundary (void)
1483 #define GROUP "main_section"
1484 #define KEY_PREFIX "fill_abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvw_"
1485 #define FIRST_KEY 10
1489 g_test_bug ("640695");
1491 file
= g_key_file_new ();
1494 g_key_file_load_from_file (file
, g_test_get_filename (G_TEST_DIST
, "pages.ini", NULL
), G_KEY_FILE_NONE
, &error
);
1495 g_assert_no_error (error
);
1497 for (i
= FIRST_KEY
; i
<= LAST_KEY
; i
++)
1502 key
= g_strdup_printf (KEY_PREFIX
"%d", i
);
1503 val
= g_key_file_get_integer (file
, GROUP
, key
, &error
);
1505 g_assert_no_error (error
);
1506 g_assert_cmpint (val
, ==, VALUE
);
1509 g_key_file_free (file
);
1516 static const char data
[] =
1521 file
= g_key_file_new ();
1523 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, NULL
);
1525 g_assert (g_key_file_has_key (file
, "group", "a", NULL
));
1526 g_key_file_ref (file
);
1527 g_key_file_free (file
);
1528 g_key_file_unref (file
);
1531 /* https://bugzilla.gnome.org/show_bug.cgi?id=634232 */
1533 test_replace_value (void)
1537 keyfile
= g_key_file_new();
1538 g_key_file_set_value(keyfile
, "grupo1", "chave1", "1234567890");
1539 g_key_file_set_value(keyfile
, "grupo1", "chave1", "123123423423423432432423423");
1540 g_key_file_remove_group(keyfile
, "grupo1", NULL
);
1541 g_free (g_key_file_to_data (keyfile
, NULL
, NULL
));
1542 g_key_file_unref (keyfile
);
1546 test_list_separator (void)
1549 GError
*error
= NULL
;
1555 keyfile
= g_key_file_new ();
1556 g_key_file_set_list_separator (keyfile
, ',');
1557 g_key_file_load_from_data (keyfile
, data
, -1, 0, &error
);
1559 check_string_list_value (keyfile
, "test", "key1", "v1", "v2", NULL
);
1560 g_key_file_unref (keyfile
);
1564 test_empty_string (void)
1566 GError
*error
= NULL
;
1569 kf
= g_key_file_new ();
1571 g_key_file_load_from_data (kf
, "", 0, 0, &error
);
1572 g_assert_no_error (error
);
1574 g_key_file_load_from_data (kf
, "", -1, 0, &error
);
1575 g_assert_no_error (error
);
1577 /* NULL is a fine pointer to use if length is zero */
1578 g_key_file_load_from_data (kf
, NULL
, 0, 0, &error
);
1579 g_assert_no_error (error
);
1581 /* should not attempt to access non-NULL pointer if length is zero */
1582 g_key_file_load_from_data (kf
, GINT_TO_POINTER (1), 0, 0, &error
);
1583 g_assert_no_error (error
);
1585 g_key_file_unref (kf
);
1592 static const char data
[] =
1599 file
= g_key_file_new ();
1602 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, &error
);
1604 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_GROUP_NOT_FOUND
);
1605 g_clear_error (&error
);
1606 g_key_file_free (file
);
1613 static const char data
[] =
1615 "Encoding=non-UTF-8\n";
1619 file
= g_key_file_new ();
1622 ok
= g_key_file_load_from_data (file
, data
, strlen (data
), 0, &error
);
1624 g_assert_error (error
, G_KEY_FILE_ERROR
, G_KEY_FILE_ERROR_UNKNOWN_ENCODING
);
1625 g_clear_error (&error
);
1626 g_key_file_free (file
);
1630 test_roundtrip (void)
1633 const gchar orig
[] =
1642 kf
= load_data (orig
, G_KEY_FILE_KEEP_COMMENTS
);
1643 g_key_file_set_integer (kf
, "Group1", "key2", 0);
1644 g_key_file_remove_key (kf
, "Group1", "key2", NULL
);
1646 data
= g_key_file_to_data (kf
, &len
, NULL
);
1647 g_assert_cmpstr (data
, ==, orig
);
1650 g_key_file_free (kf
);
1656 const gchar data
[] =
1663 GKeyFile
*kf
= g_key_file_new ();
1664 GBytes
*bytes
= g_bytes_new (data
, strlen (data
));
1665 GError
*error
= NULL
;
1670 g_key_file_load_from_bytes (kf
, bytes
, 0, &error
);
1672 g_assert_no_error (error
);
1674 names
= g_key_file_get_groups (kf
, &len
);
1675 g_assert_nonnull (names
);
1677 check_length ("groups", g_strv_length (names
), len
, 2);
1678 check_name ("group name", names
[0], "Group1", 0);
1679 check_name ("group name", names
[1], "Group2", 1);
1681 check_string_value (kf
, "Group1", "key1", "value1");
1682 check_string_value (kf
, "Group2", "key2", "value2");
1685 g_bytes_unref (bytes
);
1686 g_key_file_free (kf
);
1690 main (int argc
, char *argv
[])
1692 g_test_init (&argc
, &argv
, NULL
);
1695 g_setenv ("XDG_DATA_HOME", g_test_get_dir (G_TEST_DIST
), TRUE
);
1698 g_test_bug_base ("http://bugzilla.gnome.org/");
1700 g_test_add_func ("/keyfile/line-ends", test_line_ends
);
1701 g_test_add_func ("/keyfile/whitespace", test_whitespace
);
1702 g_test_add_func ("/keyfile/comments", test_comments
);
1703 g_test_add_func ("/keyfile/listing", test_listing
);
1704 g_test_add_func ("/keyfile/string", test_string
);
1705 g_test_add_func ("/keyfile/boolean", test_boolean
);
1706 g_test_add_func ("/keyfile/number", test_number
);
1707 g_test_add_func ("/keyfile/locale-string", test_locale_string
);
1708 g_test_add_func ("/keyfile/lists", test_lists
);
1709 g_test_add_func ("/keyfile/lists-set-get", test_lists_set_get
);
1710 g_test_add_func ("/keyfile/group-remove", test_group_remove
);
1711 g_test_add_func ("/keyfile/key-remove", test_key_remove
);
1712 g_test_add_func ("/keyfile/groups", test_groups
);
1713 g_test_add_func ("/keyfile/duplicate-keys", test_duplicate_keys
);
1714 g_test_add_func ("/keyfile/duplicate-groups", test_duplicate_groups
);
1715 g_test_add_func ("/keyfile/duplicate-groups2", test_duplicate_groups2
);
1716 g_test_add_func ("/keyfile/group-names", test_group_names
);
1717 g_test_add_func ("/keyfile/key-names", test_key_names
);
1718 g_test_add_func ("/keyfile/reload", test_reload_idempotency
);
1719 g_test_add_func ("/keyfile/int64", test_int64
);
1720 g_test_add_func ("/keyfile/load", test_load
);
1721 g_test_add_func ("/keyfile/save", test_save
);
1722 g_test_add_func ("/keyfile/load-fail", test_load_fail
);
1723 g_test_add_func ("/keyfile/non-utf8", test_non_utf8
);
1724 g_test_add_func ("/keyfile/page-boundary", test_page_boundary
);
1725 g_test_add_func ("/keyfile/ref", test_ref
);
1726 g_test_add_func ("/keyfile/replace-value", test_replace_value
);
1727 g_test_add_func ("/keyfile/list-separator", test_list_separator
);
1728 g_test_add_func ("/keyfile/empty-string", test_empty_string
);
1729 g_test_add_func ("/keyfile/limbo", test_limbo
);
1730 g_test_add_func ("/keyfile/utf8", test_utf8
);
1731 g_test_add_func ("/keyfile/roundtrip", test_roundtrip
);
1732 g_test_add_func ("/keyfile/bytes", test_bytes
);
1734 return g_test_run ();