diff options
| author | Nico Golde <nico@ngolde.de> | 2010-07-09 17:19:12 +0200 | 
|---|---|---|
| committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-07-20 02:48:17 +0800 | 
| commit | 28de05336b01aa72d7f191b33467e6c57be178a4 (patch) | |
| tree | d9af4b09de02795661993ea65aff3ab57e42f94f /tests | |
| parent | 383134b5ac0b94393cd46e2f00aeb1fd6f1a540f (diff) | |
* rewrite GSM 7bit default encoding/decoding based on a lookup table as the previous code produced wrong encodings for certain characters.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/sms/sms_test.c | 17 | 
1 files changed, 16 insertions, 1 deletions
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 <daniel@totalueberwachung.de> + * (C) 2010 by Nico Golde <nico@ngolde.de>   * 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;  }  | 
