diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-02-16 09:59:31 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-02-16 09:59:31 +0100 |
commit | 91a25c2aa1776e5e5757dc317a798615c31b3854 (patch) | |
tree | e95a1b50ff94bb194b316b277cc367dad3511952 | |
parent | e00e38f9c44568f7fab643a069f86c576011ddcc (diff) | |
download | pygobject-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.c | 18 | ||||
-rw-r--r-- | tests/regressextra.h | 3 | ||||
-rw-r--r-- | tests/test_everything.py | 6 |
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): |