[gobject-introspection] tests: Marshalling tests for new GJS functionality



commit 8bbd0c3849997d41b653e12a292b43ad59c4d9ca
Author: Philip Chimento <philip chimento gmail com>
Date:   Tue Oct 11 23:00:09 2016 -0700

    tests: Marshalling tests for new GJS functionality
    
    GJS has gained some support for marshalling arrays of previously
    unsupported types. These are the marshalling tests that are needed to
    test that new functionality.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772790

 tests/gimarshallingtests.c |  128 ++++++++++++++++++++++++++++++++++++++++++++
 tests/gimarshallingtests.h |   30 ++++++++++-
 2 files changed, 157 insertions(+), 1 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 69311de..03dc119 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -1376,6 +1376,66 @@ gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length)
 }
 
 /**
+ * gi_marshalling_tests_array_int64_in:
+ * @ints: (array length=length):
+ * @length:
+ */
+void
+gi_marshalling_tests_array_int64_in (const gint64 *ints, gint length)
+{
+  g_assert_cmpint (length, ==, 4);
+  g_assert_cmpint (ints[0], ==, -1);
+  g_assert_cmpint (ints[1], ==, 0);
+  g_assert_cmpint (ints[2], ==, 1);
+  g_assert_cmpint (ints[3], ==, 2);
+}
+
+/**
+ * gi_marshalling_tests_array_uint64_in:
+ * @ints: (array length=length):
+ * @length:
+ */
+void
+gi_marshalling_tests_array_uint64_in (const guint64 *ints, gint length)
+{
+  g_assert_cmpint (length, ==, 4);
+  g_assert_cmpint (ints[0], ==, -1);
+  g_assert_cmpint (ints[1], ==, 0);
+  g_assert_cmpint (ints[2], ==, 1);
+  g_assert_cmpint (ints[3], ==, 2);
+}
+
+/**
+ * gi_marshalling_tests_array_unichar_in:
+ * @chars: (array length=length):
+ * @length:
+ */
+void
+gi_marshalling_tests_array_unichar_in (const gunichar *chars, gint length)
+{
+  unsigned ix;
+  static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
+  g_assert_cmpint (length, ==, 12);
+  for (ix = 0; ix < length; ix++)
+    g_assert_cmpuint (chars[ix], ==, expected[ix]);
+}
+
+/**
+ * gi_marshalling_tests_array_bool_in:
+ * @bools: (array length=length):
+ * @length:
+ */
+void
+gi_marshalling_tests_array_bool_in (const gboolean *bools, gint length)
+{
+  g_assert_cmpint (length, ==, 4);
+  g_assert_true (bools[0]);
+  g_assert_false (bools[1]);
+  g_assert_true (bools[2]);
+  g_assert_true (bools[3]);
+}
+
+/**
  * gi_marshalling_tests_array_struct_in:
  * @structs: (array length=length):
  */
@@ -1522,6 +1582,31 @@ gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint
 }
 
 /**
+ * gi_marshalling_tests_array_bool_out:
+ * @bools: (out) (array length=length) (transfer none):
+ */
+void
+gi_marshalling_tests_array_bool_out (gboolean **bools, gint *length)
+{
+  static const gboolean values[] = { TRUE, FALSE, TRUE, TRUE };
+
+  *length = 4;
+  *bools = values;
+}
+
+/**
+ * gi_marshalling_tests_array_unichar_out:
+ * @chars: (out) (array length=length) (transfer none):
+ */
+void
+gi_marshalling_tests_array_unichar_out (gunichar **chars, gint *length)
+{
+  static const gunichar values[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
+  *length = 12;
+  *chars = values;
+}
+
+/**
  * gi_marshalling_tests_array_inout:
  * @ints: (inout) (array length=length) (transfer none):
  * @length: (inout):
@@ -1629,6 +1714,21 @@ gi_marshalling_tests_array_zero_terminated_return_struct (void)
 }
 
 /**
+ * gi_marshalling_tests_array_zero_terminated_return_unichar:
+ *
+ * Returns: (array zero-terminated) (transfer full):
+ */
+gunichar *
+gi_marshalling_tests_array_zero_terminated_return_unichar (void)
+{
+  static const gunichar value[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
+  unsigned ix;
+  gunichar *retval = g_new0(gunichar, 13);
+  memcpy (retval, value, 12 * sizeof (gunichar));
+  return retval;
+}
+
+/**
  * gi_marshalling_tests_array_zero_terminated_in:
  * @utf8s: (array zero-terminated) (transfer none):
  */
@@ -2055,6 +2155,34 @@ gi_marshalling_tests_garray_utf8_full_inout (GArray **array_)
 }
 
 /**
+ * gi_marshalling_tests_garray_bool_none_in:
+ * @array_: (element-type gboolean) (transfer none):
+ */
+void
+gi_marshalling_tests_garray_bool_none_in (GArray *array_)
+{
+  g_assert_cmpint (array_->len, ==, 4);
+  g_assert_true (g_array_index (array_, gboolean, 0));
+  g_assert_false (g_array_index (array_, gboolean, 1));
+  g_assert_true (g_array_index (array_, gboolean, 2));
+  g_assert_true (g_array_index (array_, gboolean, 3));
+}
+
+/**
+ * gi_marshalling_tests_garray_unichar_none_in:
+ * @array_: (element-type gunichar) (transfer none):
+ */
+void
+gi_marshalling_tests_garray_unichar_none_in (GArray *array_)
+{
+  unsigned ix;
+  static const gunichar expected[] = GI_MARSHALLING_TESTS_CONSTANT_UCS4;
+  g_assert_cmpint (array_->len, ==, 12);
+  for (ix = 0; ix < array_->len; ix++)
+    g_assert_cmpuint (g_array_index (array_, gunichar, ix), ==, expected[ix]);
+}
+
+/**
  * gi_marshalling_tests_gptrarray_utf8_none_return:
  *
  * Returns: (element-type utf8) (transfer none):
diff --git a/tests/gimarshallingtests.h b/tests/gimarshallingtests.h
index fc20fd7..6a7d869 100644
--- a/tests/gimarshallingtests.h
+++ b/tests/gimarshallingtests.h
@@ -16,7 +16,9 @@ typedef struct _GIMarshallingTestsBoxedStruct GIMarshallingTestsBoxedStruct;
 
 #define GI_MARSHALLING_TESTS_CONSTANT_NUMBER 42
 #define GI_MARSHALLING_TESTS_CONSTANT_UTF8   "const \xe2\x99\xa5 utf8"
-
+#define GI_MARSHALLING_TESTS_CONSTANT_UCS4   { 0x63, 0x6f, 0x6e, 0x73, 0x74, \
+                                               0x20, 0x2665, 0x20, 0x75, 0x74, \
+                                               0x66, 0x38 }
 
 /* Booleans */
 
@@ -717,6 +719,18 @@ _GI_TEST_EXTERN
 void gi_marshalling_tests_array_uint8_in (const guint8 *chars, gint length);
 
 _GI_TEST_EXTERN
+void gi_marshalling_tests_array_int64_in (const gint64 *ints, gint length);
+
+_GI_TEST_EXTERN
+void gi_marshalling_tests_array_uint64_in (const guint64 *ints, gint length);
+
+_GI_TEST_EXTERN
+void gi_marshalling_tests_array_unichar_in (const gunichar *chars, gint length);
+
+_GI_TEST_EXTERN
+void gi_marshalling_tests_array_bool_in (const gboolean *bools, gint length);
+
+_GI_TEST_EXTERN
 void gi_marshalling_tests_array_struct_in (GIMarshallingTestsBoxedStruct **structs, gint length);
 
 _GI_TEST_EXTERN
@@ -747,6 +761,11 @@ void gi_marshalling_tests_array_out (gint **ints, gint *length);
 _GI_TEST_EXTERN
 void gi_marshalling_tests_array_out_etc (gint first, gint **ints, gint *length, gint last, gint *sum);
 
+_GI_TEST_EXTERN
+void gi_marshalling_tests_array_bool_out (gboolean **bools, gint *length);
+
+_GI_TEST_EXTERN
+void gi_marshalling_tests_array_unichar_out (gunichar **chars, gint *length);
 
 _GI_TEST_EXTERN
 void gi_marshalling_tests_array_inout (gint **ints, gint *length);
@@ -770,6 +789,9 @@ gchar **gi_marshalling_tests_array_zero_terminated_return_null (void);
 _GI_TEST_EXTERN
 GIMarshallingTestsBoxedStruct **gi_marshalling_tests_array_zero_terminated_return_struct (void);
 
+_GI_TEST_EXTERN
+gunichar *gi_marshalling_tests_array_zero_terminated_return_unichar (void);
+
 
 _GI_TEST_EXTERN
 void gi_marshalling_tests_array_zero_terminated_in (gchar **utf8s);
@@ -845,6 +867,12 @@ void gi_marshalling_tests_garray_utf8_container_inout (GArray **array_);
 _GI_TEST_EXTERN
 void gi_marshalling_tests_garray_utf8_full_inout (GArray **array_);
 
+_GI_TEST_EXTERN
+void gi_marshalling_tests_garray_bool_none_in (GArray *array_);
+
+_GI_TEST_EXTERN
+void gi_marshalling_tests_garray_unichar_none_in (GArray *array_);
+
 /* GPtrArray */
 
 _GI_TEST_EXTERN


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]