summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2011-08-30 16:43:18 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2012-01-06 15:06:12 -0500
commitbc7b3283f907b9a9a92f8e44a1101aa5cf9e928c (patch)
tree2acebb5184c371e02a33e8885a3754f217a901e5 /tests
parent02410b7e36a5bc02a07e9f9661fed672715f09f8 (diff)
downloadgobject-introspection-bc7b3283f907b9a9a92f8e44a1101aa5cf9e928c.tar.gz
tests: Add tests for flat GValue arrays
https://bugzilla.gnome.org/show_bug.cgi?id=657766
Diffstat (limited to 'tests')
-rw-r--r--tests/gimarshallingtests.c58
-rw-r--r--tests/gimarshallingtests.h8
2 files changed, 66 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 7c922d4f..f641c383 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -2917,6 +2917,64 @@ gi_marshalling_tests_gvalue_inout (GValue **value)
g_value_set_string(*value, "42");
}
+/**
+ * gi_marshalling_tests_gvalue_flat_array:
+ * @n_values: number of values
+ * @values: (array length=n_values): an array containing values
+ */
+void
+gi_marshalling_tests_gvalue_flat_array (guint n_values,
+ const GValue *values)
+{
+ g_assert (n_values == 3);
+
+ g_assert_cmpint (g_value_get_int (&values[0]), ==, 42);
+ g_assert_cmpstr (g_value_get_string (&values[1]), ==, "42");
+ g_assert_cmpint (g_value_get_boolean (&values[2]), ==, TRUE);
+}
+
+/**
+ * gi_marshalling_tests_return_gvalue_flat_array:
+ *
+ * Returns: (array fixed-size=3) (transfer full): a flat GValue array
+ */
+GValue *
+gi_marshalling_tests_return_gvalue_flat_array (void)
+{
+ GValue *array = g_new0 (GValue, 3);
+
+ g_value_init (&array[0], G_TYPE_INT);
+ g_value_set_int (&array[0], 42);
+
+ g_value_init (&array[1], G_TYPE_STRING);
+ g_value_set_static_string (&array[1], "42");
+
+ g_value_init (&array[2], G_TYPE_BOOLEAN);
+ g_value_set_boolean (&array[2], TRUE);
+
+ return array;
+}
+
+/**
+ * gi_marshalling_tests_gvalue_flat_array_round_trip:
+ * @one: The first GValue
+ * @two: The second GValue
+ * @three: The third GValue
+ *
+ * Returns: (array fixed-size=3) (transfer full): a flat array of [@one, @two, @three]
+ */
+GValue *
+gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
+ const GValue two,
+ const GValue three)
+{
+ GValue *array = g_new (GValue, 3);
+ array[0] = one;
+ array[1] = two;
+ array[2] = three;
+
+ return array;
+}
/**
* gi_marshalling_tests_gclosure_in:
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 0ad0569e..5965a82c 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -527,6 +527,14 @@ void gi_marshalling_tests_gvalue_out (GValue **value);
void gi_marshalling_tests_gvalue_inout (GValue **value);
+void gi_marshalling_tests_gvalue_flat_array (guint n_values,
+ const GValue *values);
+
+GValue *gi_marshalling_tests_return_gvalue_flat_array (void);
+
+GValue *gi_marshalling_tests_gvalue_flat_array_round_trip (const GValue one,
+ const GValue two,
+ const GValue three);
/* GClosure */