[pygobject] tests: Add a test for a out transfer-none boxed array



commit 91a25c2aa1776e5e5757dc317a798615c31b3854
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Fri Feb 16 09:59:31 2018 +0100

    tests: Add a test for a out transfer-none boxed array
    
    Makes sure we copy the array items as well.

 tests/regressextra.c     | 18 ++++++++++++++++++
 tests/regressextra.h     |  3 +++
 tests/test_everything.py |  6 ++++++
 3 files changed, 27 insertions(+)
---
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):


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