aboutsummaryrefslogtreecommitdiff
path: root/src/tests/test-charsets.c
diff options
context:
space:
mode:
authorNathan Williams <njw@chromium.org>2011-04-14 13:30:15 -0500
committerDan Williams <dcbw@redhat.com>2011-04-14 13:30:15 -0500
commitd05c87e4c80f1a56a613241d14de4faeb0a8304a (patch)
tree08585e540e8bfd8e677ac1a86c39f0b6cccb7dda /src/tests/test-charsets.c
parent0a06dd324dbcb255d28795eb78901fca21cc52c0 (diff)
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.
Diffstat (limited to 'src/tests/test-charsets.c')
-rw-r--r--src/tests/test-charsets.c11
1 files changed, 5 insertions, 6 deletions
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);