From fc538894d38780be8fb46735a07e2d36c34eaacb Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Thu, 17 Jun 2010 00:03:44 -0400 Subject: [PATCH] GSettings: enum/choices/aliases/range test cases Fix a small bug that one of the tests uncovered. --- gio/gschema-compile.c | 10 +++---- gio/strinfo.c | 2 +- gio/tests/.gitignore | 1 + gio/tests/gschema-compile.c | 27 ++++++++++++++++++- gio/tests/schema-tests/bad-choice.gschema.xml | 14 ++++++++++ gio/tests/schema-tests/bare-alias.gschema.xml | 7 +++++ .../schema-tests/choice-alias.gschema.xml | 15 +++++++++++ gio/tests/schema-tests/choice-bad.gschema.xml | 14 ++++++++++ .../schema-tests/choice-badtype.gschema.xml | 7 +++++ .../choice-invalid-alias.gschema.xml | 15 +++++++++++ .../choice-shadowed-alias.gschema.xml | 14 ++++++++++ .../choice-upside-down.gschema.xml | 14 ++++++++++ gio/tests/schema-tests/choice.gschema.xml | 14 ++++++++++ .../default-in-aliases.gschema.xml | 15 +++++++++++ .../enum-with-aliases.gschema.xml | 20 ++++++++++++++ .../enum-with-bad-default.gschema.xml | 16 +++++++++++ .../enum-with-chained-alias.gschema.xml | 21 +++++++++++++++ .../schema-tests/enum-with-choice.gschema.xml | 17 ++++++++++++ .../enum-with-invalid-alias.gschema.xml | 20 ++++++++++++++ .../enum-with-repeated-alias.gschema.xml | 21 +++++++++++++++ .../enum-with-shadow-alias.gschema.xml | 20 ++++++++++++++ gio/tests/schema-tests/enum.gschema.xml | 16 +++++++++++ .../schema-tests/range-badtype.gschema.xml | 7 +++++ .../range-default-high.gschema.xml | 8 ++++++ .../range-default-low.gschema.xml | 8 ++++++ .../range-high-default.gschema.xml | 8 ++++++ .../range-low-default.gschema.xml | 8 ++++++ .../range-parse-error.gschema.xml | 8 ++++++ gio/tests/schema-tests/range.gschema.xml | 8 ++++++ 29 files changed, 368 insertions(+), 7 deletions(-) create mode 100644 gio/tests/schema-tests/bad-choice.gschema.xml create mode 100644 gio/tests/schema-tests/bare-alias.gschema.xml create mode 100644 gio/tests/schema-tests/choice-alias.gschema.xml create mode 100644 gio/tests/schema-tests/choice-bad.gschema.xml create mode 100644 gio/tests/schema-tests/choice-badtype.gschema.xml create mode 100644 gio/tests/schema-tests/choice-invalid-alias.gschema.xml create mode 100644 gio/tests/schema-tests/choice-shadowed-alias.gschema.xml create mode 100644 gio/tests/schema-tests/choice-upside-down.gschema.xml create mode 100644 gio/tests/schema-tests/choice.gschema.xml create mode 100644 gio/tests/schema-tests/default-in-aliases.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-aliases.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-bad-default.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-chained-alias.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-choice.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-invalid-alias.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-repeated-alias.gschema.xml create mode 100644 gio/tests/schema-tests/enum-with-shadow-alias.gschema.xml create mode 100644 gio/tests/schema-tests/enum.gschema.xml create mode 100644 gio/tests/schema-tests/range-badtype.gschema.xml create mode 100644 gio/tests/schema-tests/range-default-high.gschema.xml create mode 100644 gio/tests/schema-tests/range-default-low.gschema.xml create mode 100644 gio/tests/schema-tests/range-high-default.gschema.xml create mode 100644 gio/tests/schema-tests/range-low-default.gschema.xml create mode 100644 gio/tests/schema-tests/range-parse-error.gschema.xml create mode 100644 gio/tests/schema-tests/range.gschema.xml diff --git a/gio/gschema-compile.c b/gio/gschema-compile.c index 87fd3fb2e..dd4a44556 100644 --- a/gio/gschema-compile.c +++ b/gio/gschema-compile.c @@ -252,7 +252,7 @@ key_state_set_range (KeyState *state, gchar *type = g_variant_type_dup_string (state->type); g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - " not allowed for keys of type \"%s\"\n", type); + " not allowed for keys of type '%s'", type); g_free (type); return; } @@ -1034,11 +1034,11 @@ start_element (GMarkupParseContext *context, if (container) g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, - "Element <%s> not allowed inside <%s>\n", + "Element <%s> not allowed inside <%s>", element_name, container); else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, - "Element <%s> not allowed at toplevel\n", element_name); + "Element <%s> not allowed at toplevel", element_name); } /* 2}}} */ /* End element {{{2 */ @@ -1056,7 +1056,7 @@ key_state_end (KeyState **state_ptr, { g_set_error_literal (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - "element is required in \n"); + "element is required in "); return; } } @@ -1128,7 +1128,7 @@ text (GMarkupParseContext *context, else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - "text may not appear inside <%s>\n", + "text may not appear inside <%s>", g_markup_parse_context_get_element (context)); break; diff --git a/gio/strinfo.c b/gio/strinfo.c index 04c90c060..9ba18aa40 100644 --- a/gio/strinfo.c +++ b/gio/strinfo.c @@ -304,5 +304,5 @@ strinfo_builder_contains (GString *builder, return strinfo_find_string ((const guint32 *) builder->str, builder->len / 4, string, FALSE) != -1 || strinfo_find_string ((const guint32 *) builder->str, - builder->len / 4, string, FALSE) != -1; + builder->len / 4, string, TRUE) != -1; } diff --git a/gio/tests/.gitignore b/gio/tests/.gitignore index f0a70bc14..a4914e432 100644 --- a/gio/tests/.gitignore +++ b/gio/tests/.gitignore @@ -58,3 +58,4 @@ test.mo unix-fd unix-streams utf8-input-streamgdbus-addresses +org.gtk.test.enums.xml diff --git a/gio/tests/gschema-compile.c b/gio/tests/gschema-compile.c index 9201abd8e..477bab998 100644 --- a/gio/tests/gschema-compile.c +++ b/gio/tests/gschema-compile.c @@ -66,7 +66,32 @@ static const SchemaTest tests[] = { { "bad-key4", NULL, "*invalid name*" }, { "bad-key4", "--allow-any-name", NULL }, { "empty-key", NULL, "*empty names*" }, - { "empty-key", "--allow-any-name", "*empty names*" } + { "empty-key", "--allow-any-name", "*empty names*" }, + { "enum", NULL, NULL }, + { "enum-with-aliases", NULL, NULL }, + { "enum-with-invalid-alias", NULL, "*'banger' is not in enumerated type*" }, + { "enum-with-repeated-alias", NULL, "* already specified*" }, + { "enum-with-chained-alias", NULL, "*'sausages' is not in enumerated type*" }, + { "enum-with-shadow-alias", NULL, "*'mash' is already a member of the enum*" }, + { "enum-with-choice", NULL, "* can not be specified*" }, + { "enum-with-bad-default", NULL, "* is not a valid member*" }, + { "choice", NULL, NULL }, + { "choice-upside-down", NULL, NULL }, + { "bad-choice", NULL, "* contains string not in *" }, + { "choice-bad", NULL, "* contains string not in *" }, + { "choice-badtype", NULL, "* not allowed for keys of type 'i'*" }, + { "bare-alias", NULL, "*enumerated types or after *" }, + { "choice-alias", NULL, NULL }, + { "default-in-aliases", NULL, "* contains string not in *" }, + { "choice-invalid-alias", NULL, "*'befor' is not in *" }, + { "choice-shadowed-alias", NULL, "*given when was already*" }, + { "range", NULL, NULL }, + { "range-badtype", NULL, "* not allowed for keys of type 's'*" }, + { "range-low-default", NULL, "* is not contained in the specified range*" }, + { "range-high-default", NULL, "* is not contained in the specified range*" }, + { "range-default-low", NULL, "* is not contained in the specified range*" }, + { "range-default-high", NULL, "* is not contained in the specified range*" }, + { "range-parse-error", NULL, "*invalid character in number*" } }; int diff --git a/gio/tests/schema-tests/bad-choice.gschema.xml b/gio/tests/schema-tests/bad-choice.gschema.xml new file mode 100644 index 000000000..07640d5de --- /dev/null +++ b/gio/tests/schema-tests/bad-choice.gschema.xml @@ -0,0 +1,14 @@ + + + + 'how' + + + + + + + + + + diff --git a/gio/tests/schema-tests/bare-alias.gschema.xml b/gio/tests/schema-tests/bare-alias.gschema.xml new file mode 100644 index 000000000..52184cd8c --- /dev/null +++ b/gio/tests/schema-tests/bare-alias.gschema.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gio/tests/schema-tests/choice-alias.gschema.xml b/gio/tests/schema-tests/choice-alias.gschema.xml new file mode 100644 index 000000000..d5c92793a --- /dev/null +++ b/gio/tests/schema-tests/choice-alias.gschema.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + 'after' + + + diff --git a/gio/tests/schema-tests/choice-bad.gschema.xml b/gio/tests/schema-tests/choice-bad.gschema.xml new file mode 100644 index 000000000..4a2dbc22b --- /dev/null +++ b/gio/tests/schema-tests/choice-bad.gschema.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + 'how' + + + diff --git a/gio/tests/schema-tests/choice-badtype.gschema.xml b/gio/tests/schema-tests/choice-badtype.gschema.xml new file mode 100644 index 000000000..88104c5ec --- /dev/null +++ b/gio/tests/schema-tests/choice-badtype.gschema.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gio/tests/schema-tests/choice-invalid-alias.gschema.xml b/gio/tests/schema-tests/choice-invalid-alias.gschema.xml new file mode 100644 index 000000000..ae5bcd3a4 --- /dev/null +++ b/gio/tests/schema-tests/choice-invalid-alias.gschema.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + 'after' + + + diff --git a/gio/tests/schema-tests/choice-shadowed-alias.gschema.xml b/gio/tests/schema-tests/choice-shadowed-alias.gschema.xml new file mode 100644 index 000000000..fb68e3282 --- /dev/null +++ b/gio/tests/schema-tests/choice-shadowed-alias.gschema.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + 'after' + + + diff --git a/gio/tests/schema-tests/choice-upside-down.gschema.xml b/gio/tests/schema-tests/choice-upside-down.gschema.xml new file mode 100644 index 000000000..ea6f5323b --- /dev/null +++ b/gio/tests/schema-tests/choice-upside-down.gschema.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + 'who' + + + diff --git a/gio/tests/schema-tests/choice.gschema.xml b/gio/tests/schema-tests/choice.gschema.xml new file mode 100644 index 000000000..c9d74262e --- /dev/null +++ b/gio/tests/schema-tests/choice.gschema.xml @@ -0,0 +1,14 @@ + + + + 'who' + + + + + + + + + + diff --git a/gio/tests/schema-tests/default-in-aliases.gschema.xml b/gio/tests/schema-tests/default-in-aliases.gschema.xml new file mode 100644 index 000000000..81d639f15 --- /dev/null +++ b/gio/tests/schema-tests/default-in-aliases.gschema.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + 'pre' + + + diff --git a/gio/tests/schema-tests/enum-with-aliases.gschema.xml b/gio/tests/schema-tests/enum-with-aliases.gschema.xml new file mode 100644 index 000000000..e8c1e68ae --- /dev/null +++ b/gio/tests/schema-tests/enum-with-aliases.gschema.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 'spam' + + + + + + + diff --git a/gio/tests/schema-tests/enum-with-bad-default.gschema.xml b/gio/tests/schema-tests/enum-with-bad-default.gschema.xml new file mode 100644 index 000000000..aee0867b2 --- /dev/null +++ b/gio/tests/schema-tests/enum-with-bad-default.gschema.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + 'nie' + + + diff --git a/gio/tests/schema-tests/enum-with-chained-alias.gschema.xml b/gio/tests/schema-tests/enum-with-chained-alias.gschema.xml new file mode 100644 index 000000000..65c31e36f --- /dev/null +++ b/gio/tests/schema-tests/enum-with-chained-alias.gschema.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 'spam' + + + + + + + + diff --git a/gio/tests/schema-tests/enum-with-choice.gschema.xml b/gio/tests/schema-tests/enum-with-choice.gschema.xml new file mode 100644 index 000000000..50caf2137 --- /dev/null +++ b/gio/tests/schema-tests/enum-with-choice.gschema.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + 'spam' + + + + diff --git a/gio/tests/schema-tests/enum-with-invalid-alias.gschema.xml b/gio/tests/schema-tests/enum-with-invalid-alias.gschema.xml new file mode 100644 index 000000000..51a51fddd --- /dev/null +++ b/gio/tests/schema-tests/enum-with-invalid-alias.gschema.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 'spam' + + + + + + + diff --git a/gio/tests/schema-tests/enum-with-repeated-alias.gschema.xml b/gio/tests/schema-tests/enum-with-repeated-alias.gschema.xml new file mode 100644 index 000000000..a13ef8976 --- /dev/null +++ b/gio/tests/schema-tests/enum-with-repeated-alias.gschema.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + 'spam' + + + + + + + + diff --git a/gio/tests/schema-tests/enum-with-shadow-alias.gschema.xml b/gio/tests/schema-tests/enum-with-shadow-alias.gschema.xml new file mode 100644 index 000000000..52e30ee2f --- /dev/null +++ b/gio/tests/schema-tests/enum-with-shadow-alias.gschema.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + 'spam' + + + + + + + diff --git a/gio/tests/schema-tests/enum.gschema.xml b/gio/tests/schema-tests/enum.gschema.xml new file mode 100644 index 000000000..8cf5879ca --- /dev/null +++ b/gio/tests/schema-tests/enum.gschema.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + 'spam' + + + diff --git a/gio/tests/schema-tests/range-badtype.gschema.xml b/gio/tests/schema-tests/range-badtype.gschema.xml new file mode 100644 index 000000000..14a721786 --- /dev/null +++ b/gio/tests/schema-tests/range-badtype.gschema.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/gio/tests/schema-tests/range-default-high.gschema.xml b/gio/tests/schema-tests/range-default-high.gschema.xml new file mode 100644 index 000000000..b5feb3e0f --- /dev/null +++ b/gio/tests/schema-tests/range-default-high.gschema.xml @@ -0,0 +1,8 @@ + + + + 28 + + + + diff --git a/gio/tests/schema-tests/range-default-low.gschema.xml b/gio/tests/schema-tests/range-default-low.gschema.xml new file mode 100644 index 000000000..f8fb9efbe --- /dev/null +++ b/gio/tests/schema-tests/range-default-low.gschema.xml @@ -0,0 +1,8 @@ + + + + 21 + + + + diff --git a/gio/tests/schema-tests/range-high-default.gschema.xml b/gio/tests/schema-tests/range-high-default.gschema.xml new file mode 100644 index 000000000..0f01fc846 --- /dev/null +++ b/gio/tests/schema-tests/range-high-default.gschema.xml @@ -0,0 +1,8 @@ + + + + + 28 + + + diff --git a/gio/tests/schema-tests/range-low-default.gschema.xml b/gio/tests/schema-tests/range-low-default.gschema.xml new file mode 100644 index 000000000..49db491cb --- /dev/null +++ b/gio/tests/schema-tests/range-low-default.gschema.xml @@ -0,0 +1,8 @@ + + + + + 21 + + + diff --git a/gio/tests/schema-tests/range-parse-error.gschema.xml b/gio/tests/schema-tests/range-parse-error.gschema.xml new file mode 100644 index 000000000..58ddb5098 --- /dev/null +++ b/gio/tests/schema-tests/range-parse-error.gschema.xml @@ -0,0 +1,8 @@ + + + + + 25 + + + diff --git a/gio/tests/schema-tests/range.gschema.xml b/gio/tests/schema-tests/range.gschema.xml new file mode 100644 index 000000000..59118bdd9 --- /dev/null +++ b/gio/tests/schema-tests/range.gschema.xml @@ -0,0 +1,8 @@ + + + + + 25 + + +