From 1c2aea7854e468651807994ad168564c626ae58b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 21 Apr 2010 09:50:17 -0400 Subject: [PATCH] Add tests for --allow-any-name --- gio/tests/gschema-compile.c | 40 +++++++++++++-------- gio/tests/schema-tests/bad-key.gschema.xml | 2 +- gio/tests/schema-tests/bad-key2.gschema.xml | 2 +- gio/tests/schema-tests/bad-key3.gschema.xml | 2 +- gio/tests/schema-tests/bad-key4.gschema.xml | 2 +- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c index 9020c3a84..95d5226d1 100644 --- a/gio/tests/gschema-compile.c +++ b/gio/tests/gschema-compile.c @@ -7,6 +7,7 @@ typedef struct { const gchar *name; + const gchar *opt; const gchar *stderr; } SchemaTest; @@ -23,6 +24,7 @@ test_schema (gpointer data) "../gschema-compile", "--dry-run", "--one-schema-file", path, + (gchar *)test->opt, NULL }; gchar *envp[] = { NULL }; @@ -30,22 +32,32 @@ test_schema (gpointer data) g_free (filename); g_free (path); } - g_test_trap_assert_failed (); - g_test_trap_assert_stderr (test->stderr); + if (test->stderr) + { + g_test_trap_assert_failed (); + g_test_trap_assert_stderr (test->stderr); + } + else + g_test_trap_assert_passed(); } static const SchemaTest tests[] = { - { "no-default", "* is required in *" }, - { "missing-quotes", "*unknown keyword*" }, - { "incomplete-list", "*to follow array element*" }, - { "wrong-category", "*attribute 'l10n' invalid*" }, - { "bad-type", "*invalid GVariant type string*" }, - { "overflow", "*out of range*" }, - { "bad-key", "*invalid name*" }, - { "bad-key2", "*invalid name*" }, - { "bad-key3", "*invalid name*" }, - { "bad-key4", "*invalid name*" }, - { "empty-key", "*empty names*" }, + { "no-default", NULL, "* is required in *" }, + { "missing-quotes", NULL, "*unknown keyword*" }, + { "incomplete-list", NULL, "*to follow array element*" }, + { "wrong-category", NULL, "*attribute 'l10n' invalid*" }, + { "bad-type", NULL, "*invalid GVariant type string*" }, + { "overflow", NULL, "*out of range*" }, + { "bad-key", NULL, "*invalid name*" }, + { "bad-key", "--allow-any-name", NULL }, + { "bad-key2", NULL, "*invalid name*" }, + { "bad-key2", "--allow-any-name", NULL }, + { "bad-key3", NULL, "*invalid name*" }, + { "bad-key3", "--allow-any-name", NULL }, + { "bad-key4", NULL, "*invalid name*" }, + { "bad-key4", "--allow-any-name", NULL }, + { "empty-key", NULL, "*empty names*" }, + { "empty-key", "--allow-any-name", "*empty names*" }, }; int @@ -60,7 +72,7 @@ main (int argc, char *argv[]) for (i = 0; i < G_N_ELEMENTS (tests); ++i) { - gchar *name = g_strdup_printf ("/gschema/%s", tests[i].name); + gchar *name = g_strdup_printf ("/gschema/%s%s", tests[i].name, tests[i].opt ? "/opt" : ""); g_test_add_data_func (name, &tests[i], (gpointer) test_schema); g_free (name); } diff --git a/gio/tests/schema-tests/bad-key.gschema.xml b/gio/tests/schema-tests/bad-key.gschema.xml index 01745532b..f98cc7ccf 100644 --- a/gio/tests/schema-tests/bad-key.gschema.xml +++ b/gio/tests/schema-tests/bad-key.gschema.xml @@ -1,7 +1,7 @@ - + '' diff --git a/gio/tests/schema-tests/bad-key2.gschema.xml b/gio/tests/schema-tests/bad-key2.gschema.xml index 7cd8e6020..b7c4e7b0a 100644 --- a/gio/tests/schema-tests/bad-key2.gschema.xml +++ b/gio/tests/schema-tests/bad-key2.gschema.xml @@ -1,7 +1,7 @@ - + '' diff --git a/gio/tests/schema-tests/bad-key3.gschema.xml b/gio/tests/schema-tests/bad-key3.gschema.xml index aca76936d..208a02d1f 100644 --- a/gio/tests/schema-tests/bad-key3.gschema.xml +++ b/gio/tests/schema-tests/bad-key3.gschema.xml @@ -1,7 +1,7 @@ - + '' diff --git a/gio/tests/schema-tests/bad-key4.gschema.xml b/gio/tests/schema-tests/bad-key4.gschema.xml index f5291328e..6a3777cdd 100644 --- a/gio/tests/schema-tests/bad-key4.gschema.xml +++ b/gio/tests/schema-tests/bad-key4.gschema.xml @@ -1,7 +1,7 @@ - + ''