[gobject-introspection] gimarshallingtests: Add a marshalling test case for GPtrArrays and GArrays of structures
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] gimarshallingtests: Add a marshalling test case for GPtrArrays and GArrays of structures
- Date: Sun, 14 Jul 2019 21:47:53 +0000 (UTC)
commit a62855702c3bc0b10370ef25d622a32e227283bd
Author: Stéphane Seng <seng stephane gmail com>
Date: Sun Jul 14 21:47:40 2019 +0000
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.
tests/gimarshallingtests.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
tests/gimarshallingtests.h | 6 ++++++
2 files changed, 52 insertions(+)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 2c826f07..92868016 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -1954,6 +1954,29 @@ gi_marshalling_tests_garray_utf8_full_return (void)
return array;
}
+/**
+ * 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):
@@ -2245,6 +2268,29 @@ gi_marshalling_tests_gptrarray_utf8_full_return (void)
return parray;
}
+/**
+ * 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_);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]