mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-24 21:16:15 +01:00
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:
parent
06c3624412
commit
34751ad17a
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user