Update German translation
[glib.git] / gio / tests / gschema-compile.c
bloba215a846aafce5ad829d298e1a2ddbcfc0699f15
1 #include <stdlib.h>
2 #include <unistd.h>
3 #include <locale.h>
4 #include <libintl.h>
5 #include <gio/gio.h>
6 #include <gstdio.h>
8 typedef struct {
9 const gchar *name;
10 const gchar *opt;
11 const gchar *err;
12 } SchemaTest;
14 static void
15 test_schema_do_compile (gpointer data)
17 SchemaTest *test = (SchemaTest *) data;
18 gchar *filename = g_strconcat (test->name, ".gschema.xml", NULL);
19 gchar *path = g_test_build_filename (G_TEST_DIST, "schema-tests", filename, NULL);
20 gchar *argv[] = {
21 "../glib-compile-schemas",
22 "--strict",
23 "--dry-run",
24 "--schema-file", path,
25 (gchar *)test->opt,
26 NULL
28 gchar *envp[] = { NULL };
30 execve (argv[0], argv, envp);
31 g_assert_not_reached ();
34 static void
35 test_schema (gpointer data)
37 SchemaTest *test = (SchemaTest *) data;
38 gchar *child_name;
40 child_name = g_strdup_printf ("/gschema/%s%s/subprocess/do_compile", test->name, test->opt ? "/opt" : "");
41 g_test_trap_subprocess (child_name, 0, 0);
42 g_free (child_name);
44 if (test->err)
46 g_test_trap_assert_failed ();
47 g_test_trap_assert_stderr_unmatched ("*CRITICAL*");
48 g_test_trap_assert_stderr_unmatched ("*WARNING*");
49 g_test_trap_assert_stderr (test->err);
51 else
52 g_test_trap_assert_passed();
55 static const SchemaTest tests[] = {
56 { "no-default", NULL, "*<default> is required in <key>*" },
57 { "missing-quotes", NULL, "*unknown keyword*" },
58 { "incomplete-list", NULL, "*to follow array element*" },
59 { "wrong-category", NULL, "*unsupported l10n category*" },
60 { "bad-type", NULL, "*invalid GVariant type string*" },
61 { "overflow", NULL, "*out of range*" },
62 { "range-wrong-type", NULL, "*<range> not allowed for keys of type*" },
63 { "range-missing-min", NULL, NULL },
64 { "range-missing-max", NULL, NULL },
65 { "default-out-of-range", NULL, "*<default> is not contained in the specified range*" },
66 { "choices-wrong-type", NULL, "*<choices> not allowed for keys of type*" },
67 { "choice-missing-value", NULL, "*element 'choice' requires attribute 'value'*" },
68 { "default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
69 { "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*" },
70 { "bad-key", NULL, "*invalid name*" },
71 { "invalid-path", NULL, "*must begin and end with a slash*" },
72 { "bad-key", "--allow-any-name", NULL },
73 { "bad-key2", NULL, "*invalid name*" },
74 { "bad-key2", "--allow-any-name", NULL },
75 { "bad-key3", NULL, "*invalid name*" },
76 { "bad-key3", "--allow-any-name", NULL },
77 { "bad-key4", NULL, "*invalid name*" },
78 { "bad-key4", "--allow-any-name", NULL },
79 { "empty-key", NULL, "*empty names*" },
80 { "empty-key", "--allow-any-name", "*empty names*" },
81 { "enum", NULL, NULL },
82 { "enum-with-aliases", NULL, NULL },
83 { "enum-with-invalid-alias", NULL, "*'banger' is not in enumerated type*" },
84 { "enum-with-repeated-alias", NULL, "*<alias value='sausages'/> already specified*" },
85 { "enum-with-repeated-nick", NULL, "*<value nick='spam'/> already specified*" },
86 { "enum-with-repeated-value", NULL, "*value='1' already specified*" },
87 { "enum-with-chained-alias", NULL, "*'sausages' is not in enumerated type*" },
88 { "enum-with-shadow-alias", NULL, "*'mash' is already a member of the enum*" },
89 { "enum-with-choice", NULL, "*<choices> cannot be specified*" },
90 { "enum-with-bad-default", NULL, "*<default> is not a valid member*" },
91 { "choice", NULL, NULL },
92 { "choice-upside-down", NULL, NULL },
93 { "bad-choice", NULL, "*<default> contains string not in <choices>*" },
94 { "choice-bad", NULL, "*<default> contains string not in <choices>*" },
95 { "choice-badtype", NULL, "*<choices> not allowed for keys of type 'i'*" },
96 { "bare-alias", NULL, "*enumerated or flags types or after <choices>*" },
97 { "choice-alias", NULL, NULL },
98 { "default-in-aliases", NULL, "*<default> contains string not in <choices>*" },
99 { "choice-invalid-alias", NULL, "*'befor' is not in <choices>*" },
100 { "choice-shadowed-alias", NULL, "*given when <choice value='before'/> was already*" },
101 { "range", NULL, NULL },
102 { "range-badtype", NULL, "*<range> not allowed for keys of type 's'*" },
103 { "range-low-default", NULL, "*<default> is not contained in the specified range*" },
104 { "range-high-default", NULL, "*<default> is not contained in the specified range*" },
105 { "range-default-low", NULL, "*<default> is not contained in the specified range*" },
106 { "range-default-high", NULL, "*<default> is not contained in the specified range*" },
107 { "range-parse-error", NULL, "*invalid character in number*" },
108 { "from-docs", NULL, NULL },
109 { "extending", NULL, NULL },
110 { "extend-missing", NULL, "*extends not yet existing schema*" },
111 { "extend-nonlist", NULL, "*which is not a list*" },
112 { "extend-self", NULL, "*not yet existing*" },
113 { "extend-wrong-list-indirect", NULL, "*'y' does not extend 'x'*" },
114 { "extend-wrong-list", NULL, "*'y' does not extend 'x'*" },
115 { "key-in-list-indirect", NULL, "*cannot add keys to a 'list*" },
116 { "key-in-list", NULL, "*cannot add keys to a 'list*" },
117 { "list-of-missing", NULL, "*is list of not yet existing schema*" },
118 { "extend-and-shadow", NULL, "*shadows*use <override>*" },
119 { "extend-and-shadow-indirect", NULL, "*shadows*use <override>*" },
120 { "override", NULL, NULL },
121 { "override-missing", NULL, "*no <key name='bar'> to override*" },
122 { "override-range-error", NULL, "*<override> is not contained in the specified range*"},
123 { "override-then-key", NULL, "*shadows <key name='foo'> in <schema id='base'>*" },
124 { "override-twice", NULL, "*<override name='foo'> already specified*" },
125 { "override-type-error", NULL, "*invalid character in number*" },
126 { "flags-aliased-default", NULL, "*<default> * not in the specified flags type*" },
127 { "flags-bad-default", NULL, "*<default> * not in the specified flags type*" },
128 { "flags-more-than-one-bit", NULL, "*flags values must have at most 1 bit set*" },
129 { "flags-with-enum-attr", NULL, "*<enum id='flags'> not (yet) defined*" },
130 { "flags-with-enum-tag", NULL, "*<flags id='flags'> not (yet) defined*" },
131 { "summary-xmllang", NULL, "*Only one <summary> element allowed*" },
132 { "description-xmllang", NULL, "*Only one <description> element allowed*" },
133 { "summary-xmllang-and-attrs", NULL, "*attribute 'lang' invalid for element 'summary'*" },
134 { "inherit-gettext-domain", NULL, NULL },
135 { "range-type-test", NULL, NULL },
136 { "cdata", NULL, NULL }
141 main (int argc, char *argv[])
143 guint i;
145 setlocale (LC_ALL, "");
147 g_test_init (&argc, &argv, NULL);
149 for (i = 0; i < G_N_ELEMENTS (tests); ++i)
151 gchar *name;
153 name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : "");
154 g_test_add_data_func (name, &tests[i], (gpointer) test_schema);
155 g_free (name);
157 name = g_strdup_printf ("/gschema/%s%s/subprocess/do_compile", tests[i].name, tests[i].opt ? "/opt" : "");
158 g_test_add_data_func (name, &tests[i], (gpointer) test_schema_do_compile);
159 g_free (name);
162 return g_test_run ();