summaryrefslogtreecommitdiff
path: root/dbus
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-06-20 12:28:38 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-11-19 15:35:43 +0000
commitfc3d2bffd9cbac6002c5aa8c6369129e51dfcf6e (patch)
treefbeeed138aa44a0945d063c5301ed2ebd6d12d4b /dbus
parent2a339b850872094d6ebf3c42c6704105ce96a10d (diff)
downloaddbus-glib-fc3d2bffd9cbac6002c5aa8c6369129e51dfcf6e.tar.gz
Move _dbus_gvalue_utils_test into a separate binary, it only uses public API
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=40711 Reviewed-by: Dan Williams <dcbw@redhat.com>
Diffstat (limited to 'dbus')
-rw-r--r--dbus/dbus-gtest.c4
-rw-r--r--dbus/dbus-gtest.h1
-rw-r--r--dbus/dbus-gvalue-utils.c394
3 files changed, 0 insertions, 399 deletions
diff --git a/dbus/dbus-gtest.c b/dbus/dbus-gtest.c
index 59dbe5b..e149277 100644
--- a/dbus/dbus-gtest.c
+++ b/dbus/dbus-gtest.c
@@ -59,10 +59,6 @@ dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir)
g_type_init ();
- printf ("%s: running GValue util tests\n", "dbus-glib-test");
- if (!_dbus_gvalue_utils_test (test_data_dir))
- die ("gvalue utils");
-
printf ("%s: running GValue tests\n", "dbus-glib-test");
if (!_dbus_gvalue_test (test_data_dir))
die ("gvalue utils");
diff --git a/dbus/dbus-gtest.h b/dbus/dbus-gtest.h
index b94f506..940e959 100644
--- a/dbus/dbus-gtest.h
+++ b/dbus/dbus-gtest.h
@@ -30,7 +30,6 @@ gboolean _dbus_gmain_test (const char *test_data_dir);
gboolean _dbus_gobject_test (const char *test_data_dir);
gboolean _dbus_gutils_test (const char *test_data_dir);
gboolean _dbus_gvalue_test (const char *test_data_dir);
-gboolean _dbus_gvalue_utils_test (const char *test_data_dir);
void dbus_glib_internal_do_not_use_run_tests (const char *test_data_dir);
diff --git a/dbus/dbus-gvalue-utils.c b/dbus/dbus-gvalue-utils.c
index 672ed38..b517620 100644
--- a/dbus/dbus-gvalue-utils.c
+++ b/dbus/dbus-gvalue-utils.c
@@ -1368,397 +1368,3 @@ _dbus_g_type_specialized_builtins_init (void)
_dbus_g_type_register_map ("GHashTable", &hashtable_vtable, 0);
_dbus_g_type_register_struct ("GValueArray", &valuearray_vtable, 0);
}
-
-#ifdef DBUS_BUILD_TESTS
-
-typedef struct
-{
- gboolean seen_foo;
- gboolean seen_baz;
-} TestSpecializedHashData;
-
-static void
-test_specialized_hash (const GValue *key, const GValue *val, gpointer user_data)
-{
- TestSpecializedHashData *data = user_data;
-
- g_assert (G_VALUE_HOLDS_STRING (key));
- g_assert (G_VALUE_HOLDS_STRING (val));
-
- if (!strcmp (g_value_get_string (key), "foo"))
- {
- data->seen_foo = TRUE;
- g_assert (!strcmp (g_value_get_string (val), "bar"));
- }
- else if (!strcmp (g_value_get_string (key), "baz"))
- {
- data->seen_baz = TRUE;
- g_assert (!strcmp (g_value_get_string (val), "moo"));
- }
- else
- {
- g_assert_not_reached ();
- }
-}
-
-static void
-test_specialized_hash_2 (const GValue *key, const GValue *val, gpointer user_data)
-{
- TestSpecializedHashData *data = user_data;
- const GValue *realval;
-
- g_assert (G_VALUE_HOLDS_STRING (key));
- g_assert (G_VALUE_TYPE (val) == G_TYPE_VALUE);
-
- realval = g_value_get_boxed (val);
-
- if (!strcmp (g_value_get_string (key), "foo"))
- {
- data->seen_foo = TRUE;
- g_assert (G_VALUE_HOLDS_UINT (realval));
- g_assert (g_value_get_uint (realval) == 20);
- }
- else if (!strcmp (g_value_get_string (key), "baz"))
- {
- data->seen_baz = TRUE;
- g_assert (G_VALUE_HOLDS_STRING (realval));
- g_assert (!strcmp ("bar", g_value_get_string (realval)));
- }
- else
- {
- g_assert_not_reached ();
- }
-}
-
-gboolean
-_dbus_gvalue_utils_test (const char *datadir)
-{
- GType type;
-
- dbus_g_type_specialized_init ();
-
- type = dbus_g_type_get_collection ("GArray", G_TYPE_UINT);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_UINT);
- {
- GArray *instance;
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->len == 0);
-
- g_array_free (instance, TRUE);
- }
-
- type = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING);
- g_assert (dbus_g_type_is_map (type));
- g_assert (dbus_g_type_get_map_key_specialization (type) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_map_value_specialization (type) == G_TYPE_STRING);
- {
- GHashTable *instance;
- GValue val = { 0, };
- TestSpecializedHashData hashdata;
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (g_hash_table_size (instance) == 0);
- g_hash_table_insert (instance, g_strdup ("foo"), g_strdup ("bar"));
- g_hash_table_insert (instance, g_strdup ("baz"), g_strdup ("moo"));
- g_assert (g_hash_table_size (instance) == 2);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
- hashdata.seen_foo = FALSE;
- hashdata.seen_baz = FALSE;
- dbus_g_type_map_value_iterate (&val,
- test_specialized_hash,
- &hashdata);
-
- g_assert (hashdata.seen_foo);
- g_assert (hashdata.seen_baz);
-
- g_value_unset (&val);
- }
-
- type = dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE);
- g_assert (dbus_g_type_is_map (type));
- g_assert (dbus_g_type_get_map_key_specialization (type) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_map_value_specialization (type) == G_TYPE_VALUE);
- {
- GHashTable *instance;
- GValue val = { 0, };
- TestSpecializedHashData hashdata;
- DBusGTypeSpecializedAppendContext ctx;
- GValue *eltval;
-
- instance = dbus_g_type_specialized_construct (type);
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- {
- GValue keyval = { 0, };
- GValue valval = { 0, };
- g_value_init (&keyval, G_TYPE_STRING);
- g_value_set_string (&keyval, "foo");
-
- g_value_init (&valval, G_TYPE_VALUE);
- eltval = g_new0 (GValue, 1);
- g_value_init (eltval, G_TYPE_UINT);
- g_value_set_uint (eltval, 20);
- g_value_take_boxed (&valval, eltval);
- dbus_g_type_specialized_map_append (&ctx, &keyval, &valval);
- }
-
- {
- GValue keyval = { 0, };
- GValue valval = { 0, };
- g_value_init (&keyval, G_TYPE_STRING);
- g_value_set_string (&keyval, "baz");
- g_value_init (&valval, G_TYPE_VALUE);
- eltval = g_new0 (GValue, 1);
- g_value_init (eltval, G_TYPE_STRING);
- g_value_set_string (eltval, "bar");
- g_value_take_boxed (&valval, eltval);
- dbus_g_type_specialized_map_append (&ctx, &keyval, &valval);
- }
-
- hashdata.seen_foo = FALSE;
- hashdata.seen_baz = FALSE;
- dbus_g_type_map_value_iterate (&val,
- test_specialized_hash_2,
- &hashdata);
-
- g_assert (hashdata.seen_foo);
- g_assert (hashdata.seen_baz);
-
- g_value_unset (&val);
- }
-
- type = dbus_g_type_get_collection ("GSList", G_TYPE_OBJECT);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_OBJECT);
- {
- GSList *instance, *tmp, *copy;
- GValue val = {0, };
- GValue copyval = {0, };
- DBusGTypeSpecializedAppendContext ctx;
- GObject *objects[3];
- int i;
-
- instance = dbus_g_type_specialized_construct (type);
- g_assert (instance == NULL);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- for (i = 0; i < 3; i++)
- {
- GValue eltval = { 0, };
- GObject *obj = g_object_new (G_TYPE_OBJECT, NULL);
-
- g_assert (obj != NULL);
- objects[i] = obj;
- g_object_add_weak_pointer (obj, (gpointer) (objects + i));
-
- g_value_init (&eltval, G_TYPE_OBJECT);
- g_value_take_object (&eltval, obj);
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
- }
-
- dbus_g_type_specialized_collection_end_append (&ctx);
-
- instance = g_value_get_boxed (&val);
- g_assert (g_slist_length (instance) == 3);
-
- for (tmp = instance; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 1);
- }
-
- g_value_init (&copyval, type);
- g_value_copy (&val, &copyval);
-
- copy = g_value_get_boxed (&copyval);
- g_assert (g_slist_length (copy) == 3);
-
- for (tmp = copy; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 2);
- }
-
- g_value_unset (&copyval);
-
- for (i = 0; i < 3; i++)
- {
- g_assert (objects[i] != NULL);
- }
-
- for (tmp = instance; tmp; tmp = tmp->next)
- {
- GObject *obj = tmp->data;
- g_assert (G_IS_OBJECT (obj));
- g_assert (obj->ref_count == 1);
- }
-
- g_value_unset (&val);
-
- for (i = 0; i < 3; i++)
- {
- g_assert (objects[i] == NULL);
- }
- }
-
- type = dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING);
- g_assert (dbus_g_type_is_collection (type));
- g_assert (dbus_g_type_get_collection_specialization (type) == G_TYPE_STRING);
- {
- GPtrArray *instance;
- DBusGTypeSpecializedAppendContext ctx;
- GValue val = {0, };
- GValue eltval = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->len == 0);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_specialized_init_append (&val, &ctx);
-
- g_value_init (&eltval, G_TYPE_STRING);
- g_value_set_static_string (&eltval, "foo");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- g_value_reset (&eltval);
- g_value_set_static_string (&eltval, "bar");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- g_value_reset (&eltval);
- g_value_set_static_string (&eltval, "baz");
- dbus_g_type_specialized_collection_append (&ctx, &eltval);
-
- dbus_g_type_specialized_collection_end_append (&ctx);
-
- g_assert (instance->len == 3);
-
- g_assert (!strcmp ("foo", g_ptr_array_index (instance, 0)));
- g_assert (!strcmp ("bar", g_ptr_array_index (instance, 1)));
- g_assert (!strcmp ("baz", g_ptr_array_index (instance, 2)));
-
- g_value_unset (&val);
- }
-
- type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- g_assert (dbus_g_type_is_struct (type));
- g_assert (dbus_g_type_get_struct_size (type) == 3);
- g_assert (dbus_g_type_get_struct_member_type (type, 0) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_struct_member_type (type, 1) == G_TYPE_UINT);
- g_assert (dbus_g_type_get_struct_member_type (type, 2) == DBUS_TYPE_G_OBJECT_PATH);
- {
- GValueArray *instance;
- GValue val = {0, };
- GValue memval = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- g_value_init (&memval, G_TYPE_STRING);
- g_value_set_static_string (&memval, "foo");
- dbus_g_type_struct_set_member (&val, 0, &memval);
- g_value_unset (&memval);
-
- g_value_init (&memval, G_TYPE_UINT);
- g_value_set_uint (&memval, 42);
- dbus_g_type_struct_set_member (&val, 1, &memval);
- g_value_unset (&memval);
-
- g_value_init (&memval, DBUS_TYPE_G_OBJECT_PATH);
- g_value_set_static_boxed (&memval, "/bar/moo/foo/baz");
- dbus_g_type_struct_set_member (&val, 2, &memval);
- g_value_unset (&memval);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&memval, G_TYPE_STRING);
- dbus_g_type_struct_get_member (&val, 0, &memval);
- g_assert (0 == strcmp (g_value_get_string (&memval), "foo"));
- g_value_unset (&memval);
-
- g_value_init (&memval, G_TYPE_UINT);
- dbus_g_type_struct_get_member (&val, 1, &memval);
- g_assert (g_value_get_uint (&memval) == 42);
- g_value_unset (&memval);
-
- g_value_init (&memval, DBUS_TYPE_G_OBJECT_PATH);
- dbus_g_type_struct_get_member (&val, 2, &memval);
- g_assert (0 == strcmp ((gchar*) g_value_get_boxed (&memval),
- "/bar/moo/foo/baz"));
- g_value_unset (&memval);
-
- g_value_unset (&val);
- }
-
- type = dbus_g_type_get_struct ("GValueArray", G_TYPE_STRING, G_TYPE_UINT, DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);
- g_assert (dbus_g_type_is_struct (type));
- g_assert (dbus_g_type_get_struct_size (type) == 3);
- g_assert (dbus_g_type_get_struct_member_type (type, 0) == G_TYPE_STRING);
- g_assert (dbus_g_type_get_struct_member_type (type, 1) == G_TYPE_UINT);
- g_assert (dbus_g_type_get_struct_member_type (type, 2) == DBUS_TYPE_G_OBJECT_PATH);
- {
- GValueArray *instance;
- GValue val = {0, };
-
- instance = dbus_g_type_specialized_construct (type);
-
- g_assert (instance->n_values == 3);
-
- g_value_init (&val, type);
- g_value_take_boxed (&val, instance);
-
- dbus_g_type_struct_set (&val,
- 0,"foo",
- 1, 42,
- 2, "/bar/moo/foo/baz",
- G_MAXUINT);
-
- g_assert (instance->n_values == 3);
-
- {
- gchar *string;
- guint intval;
- gchar *path;
-
- dbus_g_type_struct_get (&val,
- 0, &string,
- 1, &intval,
- 2, &path,
- G_MAXUINT);
-
- g_assert (0 == strcmp (string, "foo"));
- g_assert (intval == 42);
- g_assert (0 == strcmp (path, "/bar/moo/foo/baz"));
- }
-
- g_value_unset (&val);
- }
-
-
- return TRUE;
-}
-
-
-
-#endif /* DBUS_BUILD_TESTS */