[gobject-introspection] gimarshallingtests: Fix and change byte array tests
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] gimarshallingtests: Fix and change byte array tests
- Date: Fri, 17 Jun 2011 16:16:53 +0000 (UTC)
commit fdfa839105f792890152d558882bab89d64522b5
Author: Colin Walters <walters verbum org>
Date: Fri Jun 17 12:14:58 2011 -0400
gimarshallingtests: Fix and change byte array tests
gi_marshalling_tests_bytearray_full_return was broken; there
should be no g_strdup() going on here.
While we're at it, change the expected data to actually include
non-ASCII so we're testing something a bit more interesting.
tests/gimarshallingtests.c | 18 +++++++-----------
1 files changed, 7 insertions(+), 11 deletions(-)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index af2734d..034ef8f 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -1811,14 +1811,10 @@ GByteArray *
gi_marshalling_tests_bytearray_full_return (void)
{
GByteArray *array = NULL;
- static gchar *values[] = {"0", "1", "2", "3", NULL};
- gint i;
+ guint8 data[] = {'\0', '1', '\xFF', '3'};
array = g_byte_array_new ();
- for (i = 0; values[i]; i++) {
- gchar *str = g_strdup (values[i]);
- g_byte_array_append (array, (const guint8*)str, 1);
- }
+ g_byte_array_append (array, (const guint8*)data, G_N_ELEMENTS(data));
return array;
@@ -1831,11 +1827,11 @@ gi_marshalling_tests_bytearray_full_return (void)
void
gi_marshalling_tests_bytearray_none_in (GByteArray *array_)
{
- g_assert (array_->len == 4);
- g_assert (g_array_index (array_, char, 0) == '0');
- g_assert (g_array_index (array_, char, 1) == '1');
- g_assert (g_array_index (array_, char, 2) == '2');
- g_assert (g_array_index (array_, char, 3) == '3');
+ g_assert_cmpuint (array_->len, ==, 4);
+ g_assert_cmpuint (g_array_index (array_, unsigned char, 0), ==, 0);
+ g_assert_cmpuint (g_array_index (array_, unsigned char, 1), ==, 49);
+ g_assert_cmpuint (g_array_index (array_, unsigned char, 2), ==, 0xFF);
+ g_assert_cmpuint (g_array_index (array_, unsigned char, 3), ==, 51);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]