summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2009-05-29 22:35:07 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2009-05-29 22:39:18 +0200
commit3e6a539a2f6c9d9b9e0f314077b1e49f07834560 (patch)
treef650b368993a7468fac79b959f03e3bc779430ce /tests
parentf941537d1c0a40f0906490ed160db6c79af572d3 (diff)
downloadgobject-introspection-3e6a539a2f6c9d9b9e0f314077b1e49f07834560.tar.gz
A few transfer-related tests for "Everything"
Diffstat (limited to 'tests')
-rw-r--r--tests/everything/everything.c45
-rw-r--r--tests/everything/everything.h7
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/everything/everything.c b/tests/everything/everything.c
index 52dec4ba..f2a2e309 100644
--- a/tests/everything/everything.c
+++ b/tests/everything/everything.c
@@ -325,6 +325,10 @@ test_array_gint64_in (int n_ints, gint64 *ints)
return sum;
}
+/**
+ * test_strv_in:
+ * @arr: (array zero-terminated=1) (transfer none):
+ */
gboolean
test_strv_in (char **arr)
{
@@ -340,6 +344,18 @@ test_strv_in (char **arr)
}
/**
+ * test_strv_in_container:
+ * @arr: (array zero-terminated=1) (transfer container):
+ */
+gboolean
+test_strv_in_container (char **arr)
+{
+ gboolean result = test_strv_in (arr);
+ g_free (arr);
+ return result;
+}
+
+/**
* test_array_gtype_in:
* @n_types:
* @types: (array length=n_types): List of types
@@ -378,6 +394,35 @@ test_strv_out (void)
}
/**
+ * test_strv_outarg:
+ * @retp: (array zero-terminated=1) (out) (transfer container):
+ */
+void
+test_strv_outarg (char ***retp)
+{
+ char **ret = g_new (char *, 4);
+ ret[0] = "1";
+ ret[1] = "2";
+ ret[2] = "3";
+ ret[3] = NULL;
+ *retp = ret;
+}
+
+/**
+ * test_array_int_in_take:
+ * @n_ints:
+ * @ints: (array length=n_ints) (transfer full): List of ints
+ */
+int test_array_int_in_take (int n_ints, int *ints)
+{
+ int i, sum = 0;
+ for (i = 0; i < n_ints; i++)
+ sum += ints[i];
+ g_free (ints);
+ return sum;
+}
+
+/**
* test_array_int_full_out:
* @len: length of the returned array.
* Returns: (array length=len) (transfer full): a new array of integers.
diff --git a/tests/everything/everything.h b/tests/everything/everything.h
index 2a7e3cdd..a4120dc2 100644
--- a/tests/everything/everything.h
+++ b/tests/everything/everything.h
@@ -44,8 +44,15 @@ gint32 test_array_gint32_in (int n_ints, gint32 *ints);
gint64 test_array_gint64_in (int n_ints, gint64 *ints);
char *test_array_gtype_in (int n_types, GType *types);
char **test_strv_out (void);
+void test_strv_outarg (char ***retp);
+
+/* transfer tests */
+int test_array_int_in_take (int n_ints, int *ints);
+gboolean test_strv_in_container (char **arr);
+
int *test_array_int_full_out(int *len);
int *test_array_int_none_out(int *len);
+
/* interface */
/* GList */
G_CONST_RETURN GList *test_glist_nothing_return (void);