Add testcases for <range> and <choices>
authorChristian Persch <chpe@gnome.org>
Mon, 26 Apr 2010 01:07:26 +0000 (20:07 -0500)
committerRyan Lortie <desrt@desrt.ca>
Mon, 26 Apr 2010 01:07:26 +0000 (20:07 -0500)
Bug #616102.

gio/tests/Makefile.am
gio/tests/gschema-compile.c
gio/tests/schema-tests/array-default-not-in-choices.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/choice-missing-value.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/choices-wrong-type.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/default-not-in-choices.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/default-out-of-range.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/range-missing-max.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/range-missing-min.gschema.xml [new file with mode: 0644]
gio/tests/schema-tests/range-wrong-type.gschema.xml [new file with mode: 0644]

index ba8fa6f2937226d504e2226f9047006793200d53..8be6313ce7dbb8db114f5a7aab672345aa262f89 100644 (file)
@@ -150,23 +150,37 @@ gsettings_LDADD             = $(progs_ldadd)
 gschema_compile_SOURCES          = gschema-compile.c
 gschema_compile_LDADD    = $(progs_ldadd)
 
-EXTRA_DIST +=                                     \
-       socket-common.c                           \
-       org.gtk.test.gschema                      \
-       org.gtk.test.gschema.xml                  \
-       de.po                                     \
-       schema-tests/bad-type.gschema.xml         \
-       schema-tests/incomplete-list.gschema.xml  \
-       schema-tests/missing-quotes.gschema.xml   \
-       schema-tests/no-default.gschema.xml       \
-       schema-tests/wrong-category.gschema.xml   \
-       schema-tests/overflow.gschema.xml         \
-       schema-tests/bad-key.gschema.xml          \
-       schema-tests/bad-key2.gschema.xml         \
-       schema-tests/bad-key3.gschema.xml         \
-       schema-tests/bad-key4.gschema.xml         \
-       schema-tests/empty-key.gschema.xml
-
+EXTRA_DIST += \
+       socket-common.c                                         \
+       org.gtk.test.gschema                                    \
+       org.gtk.test.gschema.xml                                \
+       de.po                                                   \
+       schema-tests/bad-type.gschema.xml                       \
+       schema-tests/incomplete-list.gschema.xml                \
+       schema-tests/missing-quotes.gschema.xml                 \
+       schema-tests/no-default.gschema.xml                     \
+       schema-tests/wrong-category.gschema.xml                 \
+       schema-tests/overflow.gschema.xml                       \
+       schema-tests/bad-key.gschema.xml                        \
+       schema-tests/bad-key2.gschema.xml                       \
+       schema-tests/bad-key3.gschema.xml                       \
+       schema-tests/bad-key4.gschema.xml                       \
+       schema-tests/empty-key.gschema.xml                      \
+       schema-tests/array-default-not-in-choices.gschema.xml   \
+       schema-tests/bad-type.gschema.xml                       \
+       schema-tests/choice-missing-value.gschema.xml           \
+       schema-tests/choices-wrong-type.gschema.xml             \
+       schema-tests/default-not-in-choices.gschema.xml         \
+       schema-tests/default-out-of-range.gschema.xml           \
+       schema-tests/incomplete-list.gschema.xml                \
+       schema-tests/missing-quotes.gschema.xml                 \
+       schema-tests/no-default.gschema.xml                     \
+       schema-tests/overflow.gschema.xml                       \
+       schema-tests/range-missing-max.gschema.xml              \
+       schema-tests/range-missing-min.gschema.xml              \
+       schema-tests/range-wrong-type.gschema.xml               \
+       schema-tests/wrong-category.gschema.xml
 MISC_STUFF = gschemas.compiled test.mo
 
 test.mo: de.po
index 67dbc173640e07f177b2e6575e41606ed6fbf53c..81ae4b70a2c9f17c59ee5b5baf32a58b4e8209c5 100644 (file)
@@ -42,22 +42,30 @@ test_schema (gpointer data)
 }
 
 static const SchemaTest tests[] = {
-  { "no-default",       NULL, "*<default> is required in <key>*"  },
-  { "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*"       },
+  { "no-default",                   NULL, "*<default> is required in <key>*"                    },
+  { "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*"                                      },
+  { "range-wrong-type",             NULL, "*<range> not allowed for keys of type*"              },
+  { "range-missing-min",            NULL, "*element 'range' requires attribute 'min'*"          },
+  { "range-missing-max",            NULL, "*element 'range' requires attribute 'max'*"          },
+  { "default-out-of-range",         NULL, "*<default> is not contained in the specified range*" },
+  { "choices-wrong-type",           NULL, "*<choices> not allowed for keys of type*"            },
+  { "choice-missing-value",         NULL, "*element 'choice' requires attribute 'value'*"       },
+  { "default-not-in-choices",       NULL, "*<default> contains string not in <choices>*"        },
+  { "array-default-not-in-choices", NULL, "*<default> contains string not in <choices>*"        },
+  { "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
diff --git a/gio/tests/schema-tests/array-default-not-in-choices.gschema.xml b/gio/tests/schema-tests/array-default-not-in-choices.gschema.xml
new file mode 100644 (file)
index 0000000..b6fffc6
--- /dev/null
@@ -0,0 +1,11 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="as">
+        <choices>
+          <choice value="first" />
+          <choice value="last" />
+        </choices>
+        <default>["first","last","second"]</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/choice-missing-value.gschema.xml b/gio/tests/schema-tests/choice-missing-value.gschema.xml
new file mode 100644 (file)
index 0000000..d900fc5
--- /dev/null
@@ -0,0 +1,10 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="s">
+        <choices>
+          <choice />
+        </choices>
+        <default>"a"</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/choices-wrong-type.gschema.xml b/gio/tests/schema-tests/choices-wrong-type.gschema.xml
new file mode 100644 (file)
index 0000000..7e6f14c
--- /dev/null
@@ -0,0 +1,8 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="(is)">
+        <choices />
+        <default>(1,"a")</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/default-not-in-choices.gschema.xml b/gio/tests/schema-tests/default-not-in-choices.gschema.xml
new file mode 100644 (file)
index 0000000..ec4a08d
--- /dev/null
@@ -0,0 +1,11 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="s">
+        <choices>
+          <choice value="first" />
+          <choice value="last" />
+        </choices>
+        <default>"next-to-last"</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/default-out-of-range.gschema.xml b/gio/tests/schema-tests/default-out-of-range.gschema.xml
new file mode 100644 (file)
index 0000000..8b3cbd3
--- /dev/null
@@ -0,0 +1,8 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="i">
+        <range min="0" max="100" />
+        <default>-1</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/range-missing-max.gschema.xml b/gio/tests/schema-tests/range-missing-max.gschema.xml
new file mode 100644 (file)
index 0000000..8e8bd55
--- /dev/null
@@ -0,0 +1,8 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="i">
+        <range min="100" />
+        <default>2</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/range-missing-min.gschema.xml b/gio/tests/schema-tests/range-missing-min.gschema.xml
new file mode 100644 (file)
index 0000000..f4de90c
--- /dev/null
@@ -0,0 +1,8 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="i">
+        <range max="100" />
+        <default>2</default>
+      </key>
+    </schema>
+</schemalist>
diff --git a/gio/tests/schema-tests/range-wrong-type.gschema.xml b/gio/tests/schema-tests/range-wrong-type.gschema.xml
new file mode 100644 (file)
index 0000000..033767f
--- /dev/null
@@ -0,0 +1,8 @@
+<schemalist>
+    <schema id="test">
+      <key name="test" type="s">
+        <range min="a" max="z" />
+        <default>"a"</default>
+      </key>
+    </schema>
+</schemalist>