Add a test for dictionaries in settings

This should clarify the questions in
https://bugzilla.gnome.org/show_bug.cgi?id=771968
This commit is contained in:
Matthias Clasen 2016-09-26 06:21:20 -04:00
parent 06c3624412
commit 34751ad17a
2 changed files with 25 additions and 0 deletions

View File

@ -335,6 +335,7 @@ test_complex_types (void)
gchar *s;
gint i1, i2;
GVariantIter *iter = NULL;
GVariant *v = NULL;
settings = g_settings_new ("org.gtk.test.complex-types");
@ -370,6 +371,22 @@ test_complex_types (void)
g_assert (!g_variant_iter_next (iter, "i", &i1));
g_variant_iter_free (iter);
g_settings_get (settings, "test-dict", "a{sau}", &iter);
g_assert_cmpint (g_variant_iter_n_children (iter), ==, 2);
g_assert (g_variant_iter_next (iter, "{&s@au}", &s, &v));
g_assert_cmpstr (s, ==, "AC");
g_assert_cmpstr ((char *)g_variant_get_type (v), ==, "au");
g_variant_unref (v);
g_assert (g_variant_iter_next (iter, "{&s@au}", &s, &v));
g_assert_cmpstr (s, ==, "IV");
g_assert_cmpstr ((char *)g_variant_get_type (v), ==, "au");
g_variant_unref (v);
g_variant_iter_free (iter);
v = g_settings_get_value (settings, "test-dict");
g_assert_cmpstr ((char *)g_variant_get_type (v), ==, "a{sau}");
g_variant_unref (v);
g_object_unref (settings);
}

View File

@ -66,6 +66,14 @@
<key name="test-array" type="ai">
<default>[0,1,2,3,4,5]</default>
</key>
<key name="test-dict" type="a{sau}">
<default>
{
"AC": [0,0, 0,0,0,0,0,0],
"IV": [0,0, 0,0,0,0,0,0]
}
</default>
</key>
</schema>
<schema id="org.gtk.test.localized" path="/tests/localized/" gettext-domain="test">