From 28de05336b01aa72d7f191b33467e6c57be178a4 Mon Sep 17 00:00:00 2001 From: Nico Golde Date: Fri, 9 Jul 2010 17:19:12 +0200 Subject: * rewrite GSM 7bit default encoding/decoding based on a lookup table as the previous code produced wrong encodings for certain characters. --- tests/sms/sms_test.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/sms') diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c index f5183d54..4daf003a 100644 --- a/tests/sms/sms_test.c +++ b/tests/sms/sms_test.c @@ -1,5 +1,6 @@ /* * (C) 2008 by Daniel Willmann + * (C) 2010 by Nico Golde * All Rights Reserved * * This program is free software; you can redistribute it and/or modify @@ -32,7 +33,7 @@ int main(int argc, char** argv) uint8_t *sms; uint8_t i; - /* test 7-bit coding/decoding */ + /* test 7-bit coding/decoding */ const char *input = "test text"; uint8_t length; uint8_t coded[256]; @@ -43,5 +44,19 @@ int main(int argc, char** argv) if (strcmp(result, input) != 0) { printf("7 Bit coding failed... life sucks\n"); printf("Wanted: '%s' got '%s'\n", input, result); + return -1; } + + memset(coded, 0, sizeof(coded)); + memset(result, 0, sizeof(coded)); + input = strdup("!$ a more#^- complicated test@@?_\%! case"); + length = gsm_7bit_encode(coded, input); + gsm_7bit_decode(result, coded, length); + if (strcmp(result, input) != 0) { + printf("7 Bit coding failed... life sucks\n"); + printf("Wanted: '%s' got '%s'\n", input, result); + return -2; + } + + return 0; } -- cgit v1.2.3