All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH_v2] unit: Update test_invalid() unit test
Date: Wed, 18 Jul 2012 17:18:12 +0200	[thread overview]
Message-ID: <1342624692-3773-1-git-send-email-guillaume.zajac@linux.intel.com> (raw)

[-- 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


             reply	other threads:[~2012-07-18 15:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 15:18 Guillaume Zajac [this message]
2012-07-17 19:29 ` [PATCH_v2] unit: Update test_invalid() unit test Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342624692-3773-1-git-send-email-guillaume.zajac@linux.intel.com \
    --to=guillaume.zajac@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.