From 34751ad17ac8e73558c530d15a3398273a5f4f67 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 26 Sep 2016 06:21:20 -0400 Subject: [PATCH] Add a test for dictionaries in settings This should clarify the questions in https://bugzilla.gnome.org/show_bug.cgi?id=771968 --- gio/tests/gsettings.c | 17 +++++++++++++++++ gio/tests/org.gtk.test.gschema.xml.orig | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c index f0bd89f06..18d28c25d 100644 --- a/gio/tests/gsettings.c +++ b/gio/tests/gsettings.c @@ -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); } diff --git a/gio/tests/org.gtk.test.gschema.xml.orig b/gio/tests/org.gtk.test.gschema.xml.orig index bda05a25c..c07558335 100644 --- a/gio/tests/org.gtk.test.gschema.xml.orig +++ b/gio/tests/org.gtk.test.gschema.xml.orig @@ -66,6 +66,14 @@ [0,1,2,3,4,5] + + + { + "AC": [0,0, 0,0,0,0,0,0], + "IV": [0,0, 0,0,0,0,0,0] + } + +