Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
Date: Thu, 12 Feb 2015 13:04:37 -0600	[thread overview]
Message-ID: <54DCF945.8070105@gmail.com> (raw)
In-Reply-To: <1423753800-17543-3-git-send-email-tommi.kenakkala@tieto.com>

[-- Attachment #1: Type: text/plain, Size: 4028 bytes --]

Hi Tommi,

On 02/12/2015 09:10 AM, Tommi Kenakkala wrote:
> ---
>   unit/test-sms.c |   52 ++++++++++++++++++++++++++++++++++++++++++++++++----
>   1 file changed, 48 insertions(+), 4 deletions(-)
>
> diff --git a/unit/test-sms.c b/unit/test-sms.c
> index 7b644df..5b4a37f 100644
> --- a/unit/test-sms.c
> +++ b/unit/test-sms.c
> @@ -38,6 +38,12 @@ static const char *simple_deliver = "07911326040000F0"
>   		"040B911346610089F60000208062917314480CC8F71D14969741F977FD07";
>   static const char *alnum_sender = "0791447758100650"
>   		"040DD0F334FC1CA6970100008080312170224008D4F29CDE0EA7D9";
> +static const char *unicode_deliver = "04819999990414D0FBFD7EBFDFEFF77BFE1E001"
> +		"9512090801361807E00DC00FC00C400E400D600F600C500E500D800F800C"
> +		"600E600C700E700C900E900CA00EA00DF003100320033003400350036003"
> +		"7003800390030002000540068006900730020006D0065007300730061006"
> +		"7006500200069007300200036003300200075006E00690063006F0064006"
> +		"5002000630068006100720073002E";
>   static const char *simple_submit = "0011000B916407281553F80000AA"
>   		"0AE8329BFD4697D9EC37";
>
> @@ -298,13 +304,16 @@ static void test_deliver_encode(void)
>   	int encoded_pdu_len;
>   	int encoded_tpdu_len;
>   	char *encoded_pdu;
> +	unsigned int smsc_len;
>
> +	/* test simple_deliver */
>   	decoded_pdu = decode_hex(simple_deliver, -1, &pdu_len, 0);
>
>   	g_assert(decoded_pdu);
>   	g_assert(pdu_len == (long)strlen(simple_deliver) / 2);
>
> -	ret = sms_decode(decoded_pdu, pdu_len, FALSE, 30, &sms);
> +	smsc_len = decoded_pdu[0] + 1;
> +	ret = sms_decode(decoded_pdu, pdu_len, FALSE, pdu_len - smsc_len, &sms);
>

This seems extraneous to this patch.  Probably belongs in a separate patch.

>   	g_free(decoded_pdu);
>
> @@ -322,7 +331,7 @@ static void test_deliver_encode(void)
>   	}
>
>   	g_assert(ret);
> -	g_assert(encoded_tpdu_len == 30);
> +	g_assert(encoded_tpdu_len == pdu_len - smsc_len);

as above.

>   	g_assert(encoded_pdu_len == pdu_len);
>
>   	encoded_pdu = encode_hex(pdu, encoded_pdu_len, 0);
> @@ -331,12 +340,14 @@ static void test_deliver_encode(void)
>
>   	g_free(encoded_pdu);
>
> +	/* test alnum_sender */
>   	decoded_pdu = decode_hex(alnum_sender, -1, &pdu_len, 0);
>
>   	g_assert(decoded_pdu);
>   	g_assert(pdu_len == (long)strlen(alnum_sender) / 2);
>
> -	ret = sms_decode(decoded_pdu, pdu_len, FALSE, 27, &sms);
> +	smsc_len = decoded_pdu[0] + 1;
> +	ret = sms_decode(decoded_pdu, pdu_len, FALSE, pdu_len - smsc_len, &sms);

as above

>
>   	g_free(decoded_pdu);
>
> @@ -354,7 +365,7 @@ static void test_deliver_encode(void)
>   	}
>
>   	g_assert(ret);
> -	g_assert(encoded_tpdu_len == 27);
> +	g_assert(encoded_tpdu_len == pdu_len - smsc_len);

as above

>   	g_assert(encoded_pdu_len == pdu_len);
>
>   	encoded_pdu = encode_hex(pdu, encoded_pdu_len, 0);
> @@ -362,6 +373,39 @@ static void test_deliver_encode(void)
>   	g_assert(strcmp(alnum_sender, encoded_pdu) == 0);
>
>   	g_free(encoded_pdu);
> +
> +	/* test unicode_deliver*/
> +	decoded_pdu = decode_hex(unicode_deliver, -1, &pdu_len, 0);
> +	g_assert(decoded_pdu);
> +	g_assert(pdu_len == (long)strlen(unicode_deliver) / 2);
> +
> +	smsc_len = decoded_pdu[0] + 1;
> +	ret = sms_decode(decoded_pdu, pdu_len, FALSE, pdu_len - smsc_len, &sms);
> +
> +	g_free(decoded_pdu);
> +
> +	g_assert(ret);
> +	g_assert(sms.type == SMS_TYPE_DELIVER);
> +
> +	ret = sms_encode(&sms, &encoded_pdu_len, &encoded_tpdu_len, pdu);
> +
> +	if (g_test_verbose()) {
> +		int i;
> +
> +		for (i = 0; i < encoded_pdu_len; i++)
> +			g_print("%02X", pdu[i]);
> +		g_print("\n");
> +	}
> +
> +	g_assert(ret);
> +	g_assert(encoded_tpdu_len == pdu_len - smsc_len);
> +	g_assert(encoded_pdu_len == pdu_len);
> +
> +	encoded_pdu = encode_hex(pdu, encoded_pdu_len, 0);
> +
> +	g_assert(strcmp(unicode_deliver, encoded_pdu) == 0);
> +
> +	g_free(encoded_pdu);
>   }
>
>   static void test_simple_submit(void)
>

Regards,
-Denis

  reply	other threads:[~2015-02-12 19:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 15:09 [PATCH 0/2] SMS-DELIVER Alphanum TP-OA encoding/decoding fix Tommi Kenakkala
2015-02-12 15:09 ` [PATCH 1/2] sms: SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
2015-02-12 18:59   ` Denis Kenzior
2015-02-12 15:10 ` [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address Tommi Kenakkala
2015-02-12 19:04   ` Denis Kenzior [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-02-13 12:23 [PATCH 0/2] SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
2015-02-13 12:23 ` [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address Tommi Kenakkala
2015-02-13 12:47 Tommi Kenakkala
2015-02-13 16:02 ` 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=54DCF945.8070105@gmail.com \
    --to=denkenz@gmail.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