summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Seng <seng.stephane@gmail.com>2019-07-14 21:47:40 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2019-07-14 21:47:40 +0000
commita62855702c3bc0b10370ef25d622a32e227283bd (patch)
treed5b5a32175e82550a855a77117ecc6a1f9878ebb
parenta26342256df34252dcc28da0e2f4913813701005 (diff)
downloadgobject-introspection-a62855702c3bc0b10370ef25d622a32e227283bd.tar.gz
gimarshallingtests: Add a marshalling test case for GPtrArrays and GArrays of structures
Prior to this, the only marshalling test cases available for GPtrArrays were for GPtrArrays of strings. This commit adds a marshalling test case for GPtrArrays of structures, with the same objective than the gi_marshalling_tests_array_zero_terminated_return_struct() test case. This also adds a similar marshalling test case for GArrays of structures, for completeness. This is a follow-up to https://gitlab.gnome.org/GNOME/gjs/issues/9 where a regression has been detected with these types of GPtrArrays.
-rw-r--r--tests/gimarshallingtests.c46
-rw-r--r--tests/gimarshallingtests.h6
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 2c826f07..92868016 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -1955,6 +1955,29 @@ gi_marshalling_tests_garray_utf8_full_return (void)
}
/**
+ * gi_marshalling_tests_garray_boxed_struct_full_return:
+ *
+ * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
+ */
+GArray *
+gi_marshalling_tests_garray_boxed_struct_full_return (void)
+{
+ GArray *array = NULL;
+ static const glong long_values[] = { 42, 43, 44 };
+ gint i;
+
+ array = g_array_new (TRUE, TRUE, sizeof (GIMarshallingTestsBoxedStruct));
+ for (i = 0; i < 3; i++)
+ {
+ GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
+ new_struct->long_ = long_values[i];
+ g_array_append_val (array, *new_struct);
+ }
+
+ return array;
+}
+
+/**
* gi_marshalling_tests_garray_int_none_in:
* @array_: (element-type gint) (transfer none):
*/
@@ -2246,6 +2269,29 @@ gi_marshalling_tests_gptrarray_utf8_full_return (void)
}
/**
+ * gi_marshalling_tests_gptrarray_boxed_struct_full_return:
+ *
+ * Returns: (element-type GIMarshallingTestsBoxedStruct) (transfer full):
+ */
+GPtrArray *
+gi_marshalling_tests_gptrarray_boxed_struct_full_return (void)
+{
+ GPtrArray *parray = NULL;
+ static const glong long_values[] = { 42, 43, 44 };
+ gint i;
+
+ parray = g_ptr_array_new ();
+ for (i = 0; i < 3; i++)
+ {
+ GIMarshallingTestsBoxedStruct *new_struct = gi_marshalling_tests_boxed_struct_new ();
+ new_struct->long_ = long_values[i];
+ g_ptr_array_add (parray, (gpointer) new_struct);
+ }
+
+ return parray;
+}
+
+/**
* gi_marshalling_tests_gptrarray_utf8_none_in:
* @parray_: (element-type utf8) (transfer none):
*/
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index 7837acba..d5357ec9 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -834,6 +834,9 @@ GArray *gi_marshalling_tests_garray_utf8_container_return (void);
_GI_TEST_EXTERN
GArray *gi_marshalling_tests_garray_utf8_full_return (void);
+_GI_TEST_EXTERN
+GArray *gi_marshalling_tests_garray_boxed_struct_full_return (void);
+
_GI_TEST_EXTERN
void gi_marshalling_tests_garray_int_none_in (GArray *array_);
@@ -884,6 +887,9 @@ GPtrArray *gi_marshalling_tests_gptrarray_utf8_container_return (void);
_GI_TEST_EXTERN
GPtrArray *gi_marshalling_tests_gptrarray_utf8_full_return (void);
+_GI_TEST_EXTERN
+GPtrArray *gi_marshalling_tests_gptrarray_boxed_struct_full_return (void);
+
_GI_TEST_EXTERN
void gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_);