summaryrefslogtreecommitdiff
path: root/gir
diff options
context:
space:
mode:
authorSimon van der Linden <svdlinden@src.gnome.org>2009-06-24 17:16:48 +0200
committerSimon van der Linden <svdlinden@src.gnome.org>2009-06-24 17:16:48 +0200
commit0561c1e84fa9c8063de5db6b6cde13b3be7fed3d (patch)
tree9fc12d2a87fec91a93724a8d4891ac73dd4fbe8a /gir
parentf88185674fbac1cea33855e7e7760021e51eecab (diff)
downloadgobject-introspection-0561c1e84fa9c8063de5db6b6cde13b3be7fed3d.tar.gz
Add tests for array as output argument and fixed-size arrays in Everything
Add test_array_int_out to test arrays as output argument. Add test_array_fixed_size_int_in, test_array_fixed_size_int_out, and test_array_fixed_size_int_return to test fixed-size arrays as arguments. http://bugzilla.gnome.org/show_bug.cgi?id=585427
Diffstat (limited to 'gir')
-rw-r--r--gir/everything.c57
-rw-r--r--gir/everything.h4
2 files changed, 61 insertions, 0 deletions
diff --git a/gir/everything.c b/gir/everything.c
index 674a0c22..62a80109 100644
--- a/gir/everything.c
+++ b/gir/everything.c
@@ -307,6 +307,21 @@ test_array_int_in (int n_ints, int *ints)
}
/**
+ * test_array_int_out:
+ * @n_ints: (out): the length of @ints
+ * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order
+ */
+void
+test_array_int_out (int *n_ints, int **ints)
+{
+ int i;
+ *n_ints = 5;
+ *ints = g_malloc0(sizeof(**ints) * *n_ints);
+ for (i = 1; i < *n_ints; i++)
+ (*ints)[i] = (*ints)[i-1] + 1;
+}
+
+/**
* test_array_gint8_in:
* @n_ints:
* @ints: (array length=n_ints): List of ints
@@ -469,6 +484,48 @@ test_strv_outarg (char ***retp)
}
/**
+ * test_array_fixed_size_int_in:
+ * @ints: (array fixed-size=5): a list of 5 integers
+ *
+ * Returns: the sum of the items in @ints
+ */
+int
+test_array_fixed_size_int_in (int *ints)
+{
+ int i, sum = 0;
+ for (i = 0; i < 5; i++)
+ sum += ints[i];
+ return sum;
+}
+
+/**
+ * test_array_fixed_size_int_out:
+ * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
+ */
+void
+test_array_fixed_size_int_out (int **ints)
+{
+ int i;
+ *ints = g_malloc0(sizeof(**ints) * 5);
+ for (i = 1; i < 5; i++)
+ (*ints)[i] = (*ints)[i-1] + 1;
+}
+
+/**
+ * test_array_fixed_size_int_return:
+ * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4
+ */
+int *
+test_array_fixed_size_int_return (void)
+{
+ int i, *ints;
+ ints = g_malloc0(sizeof(*ints) * 5);
+ for (i = 1; i < 5; i++)
+ ints[i] = ints[i-1] + 1;
+ return ints;
+}
+
+/**
* test_array_int_in_take:
* @n_ints:
* @ints: (array length=n_ints) (transfer full): List of ints
diff --git a/gir/everything.h b/gir/everything.h
index a7d23221..8ce29c5a 100644
--- a/gir/everything.h
+++ b/gir/everything.h
@@ -44,6 +44,7 @@ char *test_utf8_out_nonconst_return (char **out);
/* array */
gboolean test_strv_in (char **arr);
int test_array_int_in (int n_ints, int *ints);
+void test_array_int_out (int *n_ints, int **ints);
int test_array_gint8_in (int n_ints, gint8 *ints);
int test_array_gint16_in (int n_ints, gint16 *ints);
gint32 test_array_gint32_in (int n_ints, gint32 *ints);
@@ -53,6 +54,9 @@ char **test_strv_out_container (void);
char **test_strv_out (void);
const char * const * test_strv_out_c (void);
void test_strv_outarg (char ***retp);
+int test_array_fixed_size_int_in (int *ints);
+void test_array_fixed_size_int_out (int **ints);
+int *test_array_fixed_size_int_return (void);
/* transfer tests */
int test_array_int_in_take (int n_ints, int *ints);