From: Matthias Clasen Date: Mon, 8 Aug 2005 16:48:23 +0000 (+0000) Subject: Add a test for endianness handling. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=eb37812fbedeca48fea746cdfc2220d83d854ad4;p=dana%2Fcg-glib.git Add a test for endianness handling. 2005-08-08 Matthias Clasen * tests/convert-test.c: Add a test for endianness handling. --- diff --git a/ChangeLog b/ChangeLog index b4af0d76..d17cb9bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-08-08 Matthias Clasen + + * tests/convert-test.c: Add a test for + endianness handling. + 2005-08-08 Sunil Mohan Adapa * configure.in: Added "te" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index b4af0d76..d17cb9bb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +2005-08-08 Matthias Clasen + + * tests/convert-test.c: Add a test for + endianness handling. + 2005-08-08 Sunil Mohan Adapa * configure.in: Added "te" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index b4af0d76..d17cb9bb 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,8 @@ +2005-08-08 Matthias Clasen + + * tests/convert-test.c: Add a test for + endianness handling. + 2005-08-08 Sunil Mohan Adapa * configure.in: Added "te" to ALL_LINGUAS. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index b4af0d76..d17cb9bb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +2005-08-08 Matthias Clasen + + * tests/convert-test.c: Add a test for + endianness handling. + 2005-08-08 Sunil Mohan Adapa * configure.in: Added "te" to ALL_LINGUAS. diff --git a/tests/convert-test.c b/tests/convert-test.c index 3fd9b9ec..3a762475 100644 --- a/tests/convert-test.c +++ b/tests/convert-test.c @@ -96,12 +96,53 @@ test_one_half (void) g_free (out); } +static void +test_byte_order (void) +{ + gchar *in_be = "\xfe\xff\x03\x93"; /* capital gamma */ + gchar *in_le = "\xff\xfe\x93\x03"; + gchar *expected = "\xce\x93"; + gchar *out; + gsize bytes_read = 0; + gsize bytes_written = 0; + GError *error = NULL; + int i; + + out = g_convert (in_le, -1, + "UTF-8", "UTF-16", + &bytes_read, &bytes_written, + &error); + + g_assert (error == NULL); + g_assert (bytes_read == 4); + g_assert (bytes_written == 2); + g_assert (strcmp (out, expected) == 0); + g_free (out); + + out = g_convert (in_le, -1, + "UTF-8", "UTF-16", + &bytes_read, &bytes_written, + &error); + + g_assert (error == NULL); + g_assert (bytes_read == 2); + g_assert (bytes_written == 2); + g_assert (strcmp (out, expected) == 0); + g_free (out); +} int main (int argc, char *argv[]) { test_iconv_state (); test_one_half (); + +#if 0 + /* this one currently fails due to + * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=165368 + */ + test_byte_order (); +#endif return 0; }