From eb37812fbedeca48fea746cdfc2220d83d854ad4 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 8 Aug 2005 16:48:23 +0000 Subject: [PATCH] Add a test for endianness handling. 2005-08-08 Matthias Clasen * tests/convert-test.c: Add a test for endianness handling. --- ChangeLog | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-12 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ tests/convert-test.c | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+) diff --git a/ChangeLog b/ChangeLog index b4af0d763..d17cb9bb0 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 b4af0d763..d17cb9bb0 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 b4af0d763..d17cb9bb0 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 b4af0d763..d17cb9bb0 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 3fd9b9ec9..3a762475d 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; }