Add tests for array as output argument and fixed-size arrays in Everything
authorSimon van der Linden <svdlinden@src.gnome.org>
Wed, 24 Jun 2009 15:16:48 +0000 (17:16 +0200)
committerSimon van der Linden <svdlinden@src.gnome.org>
Wed, 24 Jun 2009 15:16:48 +0000 (17:16 +0200)
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

gir/everything.c
gir/everything.h

index 674a0c2..62a8010 100644 (file)
@@ -306,6 +306,21 @@ test_array_int_in (int n_ints, int *ints)
   return sum;
 }
 
+/**
+ * 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:
@@ -468,6 +483,48 @@ test_strv_outarg (char ***retp)
   *retp = ret;
 }
 
+/**
+ * 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:
index a7d2322..8ce29c5 100644 (file)
@@ -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);