From: Philippe Nunes <philippe.nunes@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH v4 3/3] unit: Add test to check CBS padding character
Date: Fri, 31 Aug 2012 17:03:58 +0200 [thread overview]
Message-ID: <1346425438-12220-3-git-send-email-philippe.nunes@linux.intel.com> (raw)
In-Reply-To: <1346425438-12220-1-git-send-email-philippe.nunes@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2880 bytes --]
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
This CBS unit test is used to check that the <CR> character can
be interpreted as a wanted carriage return and not necessarily
as a padding character.
---
unit/test-sms.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/unit/test-sms.c b/unit/test-sms.c
index e510554..31e18f8 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -1236,6 +1236,10 @@ static const char *cbs2 = "0110003201114679785E96371A8D46A3D168341A8D46A3D1683"
"41A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168"
"341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D100";
+static const char *cbs3 = "001000000111E280604028180E888462C168381E90886442A95"
+ "82E988C66C3E9783EA09068442A994EA8946AC56AB95EB0986C46ABD96EB89C6EC7EBF"
+ "97EC0A070482C1A8FC8A472C96C3A9FD0A8744AAD5AAFD8AC76CB05";
+
static void test_cbs_encode_decode(void)
{
unsigned char *decoded_pdu;
@@ -1389,6 +1393,58 @@ static void test_cbs_assembly(void)
cbs_assembly_free(assembly);
}
+static void test_cbs_padding_character(void)
+{
+ unsigned char *decoded_pdu;
+ long pdu_len;
+ gboolean ret;
+ struct cbs cbs;
+ GSList *l;
+ char iso639_lang[3];
+ char *utf8;
+
+ decoded_pdu = decode_hex(cbs3, -1, &pdu_len, 0);
+
+ g_assert(decoded_pdu);
+ g_assert(pdu_len == 88);
+
+ ret = cbs_decode(decoded_pdu, pdu_len, &cbs);
+
+ g_free(decoded_pdu);
+
+ g_assert(ret);
+
+ g_assert(cbs.gs == CBS_GEO_SCOPE_CELL_IMMEDIATE);
+ g_assert(cbs.message_code == 1);
+ g_assert(cbs.update_number == 0);
+ g_assert(cbs.message_identifier == 0);
+ g_assert(cbs.dcs == 1);
+ g_assert(cbs.max_pages == 1);
+ g_assert(cbs.page == 1);
+
+ l = g_slist_append(NULL, &cbs);
+
+ utf8 = cbs_decode_text(l, iso639_lang);
+
+ g_assert(utf8);
+
+ if (g_test_verbose()) {
+ g_printf("%s\n", utf8);
+ if (iso639_lang[0] == '\0')
+ g_printf("Lang: Unspecified\n");
+ else
+ g_printf("Lang: %s\n", iso639_lang);
+ }
+
+ g_assert(strcmp(utf8, "b£$¥èéùìòÇ\x0AØø\x0DÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !\"#¤"
+ "\x25&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLM"
+ "NOPQRSTUVWXYZÄÖ") == 0);
+ g_assert(strcmp(iso639_lang, "en") == 0);
+
+ g_free(utf8);
+ g_slist_free(l);
+}
+
static const char *ranges[] = { "1-5, 2, 3, 600, 569-900, 999",
"0-20, 33, 44, 50-60, 20-50, 1-5, 5, 3, 5",
NULL };
@@ -1679,6 +1735,9 @@ int main(int argc, char **argv)
test_cbs_encode_decode);
g_test_add_func("/testsms/Test CBS Assembly", test_cbs_assembly);
+ g_test_add_func("/testsms/Test CBS Padding Character",
+ test_cbs_padding_character);
+
g_test_add_func("/testsms/Range minimizer", test_range_minimizer);
g_test_add_func("/testsms/Status Report Assembly", test_sr_assembly);
--
1.7.9.5
next prev parent reply other threads:[~2012-08-31 15:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-31 15:03 [PATCH v4 1/3] smsutil: Fix style issues Philippe Nunes
2012-08-31 15:03 ` [PATCH v4 2/3] smsutil: <CR> is not necessarily a CBS padding character Philippe Nunes
2012-09-17 16:58 ` Denis Kenzior
2012-08-31 15:03 ` Philippe Nunes [this message]
2012-09-17 16:58 ` [PATCH v4 3/3] unit: Add test to check " Denis Kenzior
2012-09-17 16:57 ` [PATCH v4 1/3] smsutil: Fix style issues 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=1346425438-12220-3-git-send-email-philippe.nunes@linux.intel.com \
--to=philippe.nunes@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox