From d05c87e4c80f1a56a613241d14de4faeb0a8304a Mon Sep 17 00:00:00 2001 From: Nathan Williams Date: Thu, 14 Apr 2011 13:30:15 -0500 Subject: charset: change GSM unpack to take number of characters rather than octets Change interface to take the number of GSM characters rather than the number of octets, so that it is possible to distinguish the 7-character and 8-character cases. --- src/tests/test-charsets.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/tests') diff --git a/src/tests/test-charsets.c b/src/tests/test-charsets.c index 656b80ca..70c796ab 100644 --- a/src/tests/test-charsets.c +++ b/src/tests/test-charsets.c @@ -98,7 +98,7 @@ test_unpack_gsm7 (void *f, gpointer d) guint8 *unpacked; guint32 unpacked_len = 0; - unpacked = gsm_unpack (gsm, sizeof (gsm), 0, &unpacked_len); + unpacked = gsm_unpack (gsm, (sizeof (gsm) * 8) / 7, 0, &unpacked_len); g_assert (unpacked); g_assert_cmpint (unpacked_len, ==, sizeof (expected)); g_assert_cmpint (memcmp (unpacked, expected, unpacked_len), ==, 0); @@ -110,17 +110,16 @@ static void test_unpack_gsm7_7_chars (void *f, gpointer d) { static const guint8 gsm[] = { 0xF1, 0x7B, 0x59, 0x4E, 0xCF, 0xD7, 0x01 }; - static const guint8 expected[] = { 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x00 }; + static const guint8 expected[] = { 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75}; guint8 *unpacked; guint32 unpacked_len = 0; /* Tests the edge case where there are 7 bits left in the packed * buffer but those 7 bits do not contain a character. In this case - * we expect a trailing NULL byte and the caller must know enough about - * the intended message to remove it when required. + * we expect to get the number of characters that were specified. */ - unpacked = gsm_unpack (gsm, sizeof (gsm), 0, &unpacked_len); + unpacked = gsm_unpack (gsm, 7 , 0, &unpacked_len); g_assert (unpacked); g_assert_cmpint (unpacked_len, ==, sizeof (expected)); g_assert_cmpint (memcmp (unpacked, expected, unpacked_len), ==, 0); @@ -153,7 +152,7 @@ test_unpack_gsm7_all_chars (void *f, gpointer d) guint32 unpacked_len = 0; int i; - unpacked = gsm_unpack (gsm, sizeof (gsm), 0, &unpacked_len); + unpacked = gsm_unpack (gsm, (sizeof (gsm) * 8) / 7, 0, &unpacked_len); g_assert (unpacked); g_assert_cmpint (unpacked_len, ==, 148); -- cgit v1.2.3-70-g09d2