summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-11-25 10:33:56 +0100
committerTomeu Vizoso <tomeu@sugarlabs.org>2009-12-22 17:58:52 +0100
commit24fa1224ff00b9da177e0bfaa1e14e1b899e4976 (patch)
tree9d987e0adf0932ddf538aaff17cb33fc5d239762 /tests
parente955b931b07113c7432f7a85f882f69f12d263ad (diff)
downloadpygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.tar.gz
pygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.tar.xz
pygi-24fa1224ff00b9da177e0bfaa1e14e1b899e4976.zip
The array field 'length' starts to count from the C arg list, so need to decrement when it's a method
https://bugzilla.gnome.org/show_bug.cgi?id=602640
Diffstat (limited to 'tests')
-rw-r--r--tests/libtestgi.c60
-rw-r--r--tests/libtestgi.h4
-rw-r--r--tests/test_gi.py15
3 files changed, 79 insertions, 0 deletions
diff --git a/tests/libtestgi.c b/tests/libtestgi.c
index ac18095..d712b19 100644
--- a/tests/libtestgi.c
+++ b/tests/libtestgi.c
@@ -3245,6 +3245,66 @@ test_gi_object_new (gint int_)
return g_object_new (TESTGI_TYPE_OBJECT, "int", int_, NULL);
}
+/**
+ * test_gi_object_method_array_in:
+ * @ints: (array length=length):
+ */
+void
+test_gi_object_method_array_in (TestGIObject *object, const gint *ints, gint length)
+{
+ g_assert(length == 4);
+ g_assert(ints[0] == -1);
+ g_assert(ints[1] == 0);
+ g_assert(ints[2] == 1);
+ g_assert(ints[3] == 2);
+}
+
+/**
+ * test_gi_object_method_array_out:
+ * @ints: (out) (array length=length) (transfer none):
+ */
+void
+test_gi_object_method_array_out (TestGIObject *object, gint **ints, gint *length)
+{
+ static gint values[] = {-1, 0, 1, 2};
+
+ *length = 4;
+ *ints = values;
+}
+
+/**
+ * test_gi_object_method_array_inout:
+ * @ints: (inout) (array length=length) (transfer none):
+ * @length: (inout):
+ */
+void
+test_gi_object_method_array_inout (TestGIObject *object, gint **ints, gint *length)
+{
+ static gint values[] = {-2, -1, 0, 1, 2};
+
+ g_assert(*length == 4);
+ g_assert((*ints)[0] == -1);
+ g_assert((*ints)[1] == 0);
+ g_assert((*ints)[2] == 1);
+ g_assert((*ints)[3] == 2);
+
+ *length = 5;
+ *ints = values;
+}
+
+/**
+ * test_gi_object_method_array_return:
+ * Returns: (array length=length):
+ */
+const gint *
+test_gi_object_method_array_return (TestGIObject *object, gint *length)
+{
+ static gint ints[] = {-1, 0, 1, 2};
+
+ *length = 4;
+ return ints;
+}
+
/**
* test_gi__object_none_return:
diff --git a/tests/libtestgi.h b/tests/libtestgi.h
index cbf6f9b..db12fd3 100644
--- a/tests/libtestgi.h
+++ b/tests/libtestgi.h
@@ -596,6 +596,10 @@ void test_gi_object_method (TestGIObject *object);
void test_gi_object_overridden_method (TestGIObject *object);
TestGIObject *test_gi_object_new (gint int_);
+void test_gi_object_method_array_in (TestGIObject *object, const gint *ints, gint length);
+void test_gi_object_method_array_out (TestGIObject *object, gint **ints, gint *length);
+void test_gi_object_method_array_inout (TestGIObject *object, gint **ints, gint *length);
+const gint *test_gi_object_method_array_return (TestGIObject *object, gint *length);
TestGIObject *test_gi__object_none_return (void);
TestGIObject *test_gi__object_full_return (void);
diff --git a/tests/test_gi.py b/tests/test_gi.py
index d776c27..d0bc36e 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -822,6 +822,21 @@ class TestArray(unittest.TestCase):
def test_array_inout(self):
self.assertEquals((-2, -1, 0, 1, 2), TestGI.array_inout(Sequence((-1, 0, 1, 2))))
+ def test_method_array_in(self):
+ object_ = TestGI.Object()
+ object_.method_array_in(Sequence((-1, 0, 1, 2)))
+
+ def test_method_array_out(self):
+ object_ = TestGI.Object()
+ self.assertEquals((-1, 0, 1, 2), object_.method_array_out())
+
+ def test_method_array_inout(self):
+ object_ = TestGI.Object()
+ self.assertEquals((-2, -1, 0, 1, 2), object_.method_array_inout(Sequence((-1, 0, 1, 2))))
+
+ def test_method_array_return(self):
+ object_ = TestGI.Object()
+ self.assertEquals((-1, 0, 1, 2), object_.method_array_return())
def test_array_fixed_out_struct(self):
struct1, struct2 = TestGI.array_fixed_out_struct()