[gobject-introspection] tests: Add tests for flat GValue arrays



commit bc7b3283f907b9a9a92f8e44a1101aa5cf9e928c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Aug 30 16:43:18 2011 -0400

    tests: Add tests for flat GValue arrays
    
    https://bugzilla.gnome.org/show_bug.cgi?id=657766

 tests/gimarshallingtests.c |   58 ++++++++++++++++++++++++++++++++++++++++++++
 tests/gimarshallingtests.h |    8 ++++++
 2 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 7c922d4..f641c38 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 0ad0569..5965a82 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 */
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]