summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Eftimie <alex@eftimie.ro>2011-06-10 08:38:19 +0300
committerJohn (J5) Palmieri <johnp@redhat.com>2011-06-17 16:49:38 -0400
commit83fe28920512a3e8bc5cdeeb3d59be6f19b80bac (patch)
treef544e8ea5e961bece6293fdf215d734d5e4659af
parentfdfa839105f792890152d558882bab89d64522b5 (diff)
downloadgobject-introspection-83fe28920512a3e8bc5cdeeb3d59be6f19b80bac.tar.gz
Added marshalling tests for GPtrArray
https://bugzilla.gnome.org/show_bug.cgi?id=652256
-rw-r--r--tests/gimarshallingtests.c242
-rw-r--r--tests/gimarshallingtests.h17
2 files changed, 259 insertions, 0 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 034ef8ff..814a6c24 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -1804,6 +1804,248 @@ gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
}
/**
+ * gi_marshalling_tests_gptrarray_int_none_return:
+ * Returns: (element-type gint) (transfer none):
+ */
+GPtrArray *
+gi_marshalling_tests_gptrarray_int_none_return (void)
+{
+ static GPtrArray *parray = NULL;
+ gint i;
+
+ if (parray == NULL) {
+ parray = g_ptr_array_new ();
+ for (i = 0; i < 4; i++) {
+ g_ptr_array_add (parray, GINT_TO_POINTER(i));
+ }
+ }
+
+ return parray;
+}
+/**
+ * gi_marshalling_tests_gptrarray_utf8_none_return:
+ * Returns: (element-type utf8) (transfer none):
+ */
+GPtrArray *
+gi_marshalling_tests_gptrarray_utf8_none_return (void)
+{
+ static GPtrArray *parray = NULL;
+ static gchar *values[] = {"0", "1", "2"};
+ gint i;
+
+ if (parray == NULL) {
+ parray = g_ptr_array_new ();
+ for (i = 0; i < 3; i++)
+ g_ptr_array_add (parray, (gpointer) values[i]);
+ }
+
+ return parray;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_container_return:
+ * Returns: (element-type utf8) (transfer container):
+ */
+GPtrArray *
+gi_marshalling_tests_gptrarray_utf8_container_return (void)
+{
+ GPtrArray *parray = NULL;
+ static gchar *values[] = {"0", "1", "2", NULL};
+ gint i;
+
+ parray = g_ptr_array_new ();
+ for (i = 0; values[i]; i++)
+ g_ptr_array_add (parray, (gpointer)values[i]);
+
+ return parray;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_full_return:
+ * Returns: (element-type utf8) (transfer full):
+ */
+GPtrArray *
+gi_marshalling_tests_gptrarray_utf8_full_return (void)
+{
+ GPtrArray *parray = NULL;
+ static gchar *values[] = {"0", "1", "2", NULL};
+ gint i;
+
+ parray = g_ptr_array_new ();
+ for (i = 0; values[i]; i++) {
+ gchar *str = g_strdup (values[i]);
+ g_ptr_array_add (parray, (gpointer)str);
+ }
+
+ return parray;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_int_none_in:
+ * @parray_: (element-type gint) (transfer none):
+ */
+void
+gi_marshalling_tests_gptrarray_int_none_in (GPtrArray *parray_)
+{
+ g_assert (parray_->len == 4);
+ g_assert (g_ptr_array_index (parray_, 0) == GINT_TO_POINTER(0));
+ g_assert (g_ptr_array_index (parray_, 1) == GINT_TO_POINTER(1));
+ g_assert (g_ptr_array_index (parray_, 2) == GINT_TO_POINTER(2));
+ g_assert (g_ptr_array_index (parray_, 3) == GINT_TO_POINTER(3));
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_none_in:
+ * @parray_: (element-type utf8) (transfer none):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_)
+{
+ g_assert (parray_->len == 3);
+ g_assert (strcmp (g_ptr_array_index (parray_, 0), "0") == 0);
+ g_assert (strcmp (g_ptr_array_index (parray_, 1), "1") == 0);
+ g_assert (strcmp (g_ptr_array_index (parray_, 2), "2") == 0);
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_none_out:
+ * @parray_: (out) (element-type utf8) (transfer none):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_)
+{
+ static GPtrArray *internal = NULL;
+ static gchar *values[] = {"0", "1", "2", NULL};
+ gint i;
+
+ if (internal == NULL) {
+ internal = g_ptr_array_new ();
+ for (i = 0; values[i]; i++)
+ g_ptr_array_add (internal, (gpointer)values[i]);
+ }
+
+ *parray_ = internal;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_container_out:
+ * @parray_: (out) (element-type utf8) (transfer container):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_)
+{
+ static gchar *values[] = {"0", "1", "2", NULL};
+ gint i;
+
+ *parray_ = NULL;
+
+ *parray_ = g_ptr_array_new ();
+ for (i = 0; values[i]; i++)
+ g_ptr_array_add (*parray_, (gpointer)values[i]);
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_full_out:
+ * @parray_: (out) (element-type utf8) (transfer full):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_)
+{
+ static gchar *values[] = {"0", "1", "2", NULL};
+ gint i;
+
+ *parray_ = NULL;
+
+ *parray_ = g_ptr_array_new ();
+ for (i = 0; values[i]; i++) {
+ gchar *str = g_strdup (values[i]);
+ g_ptr_array_add (*parray_, (gpointer)str);
+ }
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_none_inout:
+ * @parray_: (inout) (element-type utf8) (transfer none):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_)
+{
+ static GPtrArray *internal = NULL;
+ static gchar *values[] = {"-2", "-1", "0", "1", NULL};
+ gint i;
+
+ g_assert ((*parray_)->len == 3);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
+
+ if (internal == NULL) {
+ internal = g_ptr_array_new ();
+ for (i = 0; values[i]; i++)
+ g_ptr_array_add (internal, (gpointer) values[i]);
+ }
+
+ *parray_ = internal;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_container_inout:
+ * @parray_: (inout) (element-type utf8) (transfer container):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_)
+{
+ static gchar *val1 = "-2";
+ static gchar *val2 = "-1";
+ static gchar *val3 = "0";
+ static gchar *val4 = "1";
+ GPtrArray *result;
+
+ g_assert ((*parray_)->len == 3);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
+
+ result = g_ptr_array_new ();
+ g_ptr_array_add (result, (gpointer) val1);
+ g_ptr_array_add (result, (gpointer) val2);
+ g_ptr_array_add (result, (gpointer) val3);
+ g_ptr_array_add (result, (gpointer) val4);
+
+ *parray_ = result;
+}
+
+/**
+ * gi_marshalling_tests_gptrarray_utf8_full_inout:
+ * @parray_: (inout) (element-type utf8) (transfer full):
+ */
+void
+gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_)
+{
+ static gchar *val1 = "-1";
+ static gchar *val2 = "-2";
+ gchar *val;
+ GPtrArray *result;
+
+ g_assert ((*parray_)->len == 3);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 0), "0") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 1), "1") == 0);
+ g_assert (strcmp (g_ptr_array_index (*parray_, 2), "2") == 0);
+
+ result = g_ptr_array_new ();
+ val = g_strdup (val2);
+ g_ptr_array_add(result, (gpointer) val);
+ val = g_strdup (val1);
+ g_ptr_array_add(result, (gpointer) val);
+ val = g_strdup ("0");
+ g_ptr_array_add(result, (gpointer) val);
+ val = g_strdup ("1");
+ g_ptr_array_add(result, (gpointer) val);
+
+ *parray_ = result;
+}
+
+/**
* gi_marshalling_tests_bytearray_full_return:
* Returns: (transfer full):
*/
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index ae5d47cb..63a4a6a3 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -422,6 +422,23 @@ void gi_marshalling_tests_garray_utf8_none_inout (GArray **array_);
void gi_marshalling_tests_garray_utf8_container_inout (GArray **array_);
void gi_marshalling_tests_garray_utf8_full_inout (GArray **array_);
+/* GPtrArray */
+GPtrArray *gi_marshalling_tests_gptrarray_int_none_return (void);
+GPtrArray *gi_marshalling_tests_gptrarray_utf8_none_return (void);
+GPtrArray *gi_marshalling_tests_gptrarray_utf8_container_return (void);
+GPtrArray *gi_marshalling_tests_gptrarray_utf8_full_return (void);
+
+void gi_marshalling_tests_gptrarray_int_none_in (GPtrArray *parray_);
+void gi_marshalling_tests_gptrarray_utf8_none_in (GPtrArray *parray_);
+
+void gi_marshalling_tests_gptrarray_utf8_none_out (GPtrArray **parray_);
+void gi_marshalling_tests_gptrarray_utf8_container_out (GPtrArray **parray_);
+void gi_marshalling_tests_gptrarray_utf8_full_out (GPtrArray **parray_);
+
+void gi_marshalling_tests_gptrarray_utf8_none_inout (GPtrArray **parray_);
+void gi_marshalling_tests_gptrarray_utf8_container_inout (GPtrArray **parray_);
+void gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_);
+
/* GByteArray */
GByteArray *gi_marshalling_tests_bytearray_full_return (void);