summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-02-16 09:59:31 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2018-02-16 09:59:31 +0100
commit91a25c2aa1776e5e5757dc317a798615c31b3854 (patch)
treee95a1b50ff94bb194b316b277cc367dad3511952
parente00e38f9c44568f7fab643a069f86c576011ddcc (diff)
downloadpygobject-91a25c2aa1776e5e5757dc317a798615c31b3854.tar.gz
tests: Add a test for a out transfer-none boxed array
Makes sure we copy the array items as well.
-rw-r--r--tests/regressextra.c18
-rw-r--r--tests/regressextra.h3
-rw-r--r--tests/test_everything.py6
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressextra.c b/tests/regressextra.c
index 4df4eddc..9efa5986 100644
--- a/tests/regressextra.c
+++ b/tests/regressextra.c
@@ -49,3 +49,21 @@ regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self)
{
return self->cptr;
}
+
+/**
+ * regress_test_array_fixed_boxed_none_out
+ * @objs: (out) (array fixed-size=2) (transfer none): An array of #RegressTestBoxedC
+**/
+void
+regress_test_array_fixed_boxed_none_out (RegressTestBoxedC ***objs)
+{
+ static RegressTestBoxedC **arr;
+
+ if (arr == NULL) {
+ arr = g_new0 (RegressTestBoxedC *, 3);
+ arr[0] = regress_test_boxed_c_new ();
+ arr[1] = regress_test_boxed_c_new ();
+ }
+
+ *objs = arr;
+}
diff --git a/tests/regressextra.h b/tests/regressextra.h
index 0753cddc..bfc6c3b0 100644
--- a/tests/regressextra.h
+++ b/tests/regressextra.h
@@ -14,4 +14,7 @@ RegressTestBoxedCWrapper * regress_test_boxed_c_wrapper_copy (RegressTestBoxedCW
_GI_TEST_EXTERN
RegressTestBoxedC *regress_test_boxed_c_wrapper_get (RegressTestBoxedCWrapper *self);
+_GI_TEST_EXTERN
+void regress_test_array_fixed_boxed_none_out (RegressTestBoxedC ***objs);
+
#endif /* REGRESS_EXTRA_H */
diff --git a/tests/test_everything.py b/tests/test_everything.py
index ce79cc2f..ee852098 100644
--- a/tests/test_everything.py
+++ b/tests/test_everything.py
@@ -1160,6 +1160,12 @@ class TestBoxed(unittest.TestCase):
self.assertEqual(obj.refcount, 1)
del obj
+ def test_array_fixed_boxed_none_out(self):
+ arr = Everything.test_array_fixed_boxed_none_out()
+ assert len(arr) == 2
+ assert arr[0].refcount == 2
+ assert arr[1].refcount == 2
+
class TestTortureProfile(unittest.TestCase):
def test_torture_profile(self):