* Re: [PATCH_v2] unit: Update test_invalid() unit test
2012-07-18 15:18 [PATCH_v2] unit: Update test_invalid() unit test Guillaume Zajac
@ 2012-07-17 19:29 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2012-07-17 19:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
Hi Guillaume,
On 07/18/2012 10:18 AM, Guillaume Zajac wrote:
> ---
> unit/test-util.c | 26 +++++++++++++++++++++++---
> 1 files changed, 23 insertions(+), 3 deletions(-)
>
I applied this patch, but simplified it slightly in a follow-on commit.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH_v2] unit: Update test_invalid() unit test
@ 2012-07-18 15:18 Guillaume Zajac
2012-07-17 19:29 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Zajac @ 2012-07-18 15:18 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1453 bytes --]
---
unit/test-util.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/unit/test-util.c b/unit/test-util.c
index 079d775..d3bbf8c 100644
--- a/unit/test-util.c
+++ b/unit/test-util.c
@@ -345,7 +345,9 @@ static void test_invalid(void)
{
long nwritten;
long nread;
- char *res;
+ short unsigned int exp_code;
+ long exp_res_length;
+ char *res, *temp, *exp_res = NULL;
unsigned char *gsm;
res = convert_gsm_to_utf8(invalid_gsm_extended, 0, &nread, &nwritten,
@@ -356,11 +358,29 @@ static void test_invalid(void)
g_assert(res[0] == '\0');
g_free(res);
+ /*
+ * In case of invalid GSM extended code, we should display
+ * the character of the main default alphabet table.
+ */
res = convert_gsm_to_utf8(invalid_gsm_extended,
sizeof(invalid_gsm_extended),
&nread, &nwritten, 0);
- g_assert(res == NULL);
- g_assert(nread == 1);
+
+ exp_code = gsm_to_unicode_map[invalid_gsm_extended[1]*2 + 1];
+
+ exp_res_length = UTF8_LENGTH(exp_code);
+ exp_res = g_try_malloc(exp_res_length + 1);
+
+ g_assert(exp_res != NULL);
+
+ temp = exp_res;
+ temp += g_unichar_to_utf8(exp_code, temp);
+ *temp = '\0';
+
+ g_assert(g_strcmp0(res, exp_res) == 0);
+ g_assert(nread == exp_res_length);
+ g_free(exp_res);
+ g_free(res);
res = convert_gsm_to_utf8(invalid_gsm_extended_len,
sizeof(invalid_gsm_extended_len),
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-18 15:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-18 15:18 [PATCH_v2] unit: Update test_invalid() unit test Guillaume Zajac
2012-07-17 19:29 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.