gimarshallingtests: Add some GBytes tests
authorColin Walters <walters@verbum.org>
Mon, 5 Nov 2012 23:13:24 +0000 (18:13 -0500)
committerColin Walters <walters@verbum.org>
Wed, 7 Nov 2012 14:09:28 +0000 (09:09 -0500)
Will be used by gjs for new byte array work.

https://bugzilla.gnome.org/show_bug.cgi?id=687696

tests/gimarshallingtests.c
tests/gimarshallingtests.h

index e05f916..5ce800d 100644 (file)
@@ -2233,6 +2233,36 @@ gi_marshalling_tests_bytearray_none_in (GByteArray *v)
 }
 
 /**
+ * gi_marshalling_tests_gbytes_full_return:
+ *
+ * Returns: (transfer full):
+ */
+GBytes *
+gi_marshalling_tests_gbytes_full_return (void)
+{
+  static guint8 data[] = {0, 49, 0xFF, 51};
+
+  return g_bytes_new_static (data, G_N_ELEMENTS(data));
+}
+
+/**
+ * gi_marshalling_tests_gbytes_none_in:
+ */
+void
+gi_marshalling_tests_gbytes_none_in (GBytes *v)
+{
+  const guint8 *data;
+  gsize len;
+  data = g_bytes_get_data (v, &len);
+
+  g_assert_cmpuint (len, ==, 4);
+  g_assert_cmpuint (data[0], ==, 0);
+  g_assert_cmpuint (data[1], ==, 49);
+  g_assert_cmpuint (data[2], ==, 0xFF);
+  g_assert_cmpuint (data[3], ==, 51);
+}
+
+/**
  * gi_marshalling_tests_gstrv_return:
  *
  * Returns: (transfer full): an array of strings
index 73401ee..1b5d7ce 100644 (file)
@@ -459,6 +459,11 @@ void gi_marshalling_tests_gptrarray_utf8_full_inout (GPtrArray **parray_);
 GByteArray *gi_marshalling_tests_bytearray_full_return (void);
 void gi_marshalling_tests_bytearray_none_in (GByteArray* v);
 
+/* GBytes */
+
+GBytes *gi_marshalling_tests_gbytes_full_return (void);
+void gi_marshalling_tests_gbytes_none_in (GBytes* v);
+
 /* GStrv */
 
 GStrv gi_marshalling_tests_gstrv_return (void);