All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
  2015-02-12 15:09 [PATCH 0/2] SMS-DELIVER Alphanum TP-OA encoding/decoding fix Tommi Kenakkala
@ 2015-02-12 15:10 ` Tommi Kenakkala
  2015-02-12 19:04   ` Denis Kenzior
  0 siblings, 1 reply; 5+ messages in thread
From: Tommi Kenakkala @ 2015-02-12 15:10 UTC (permalink / raw)
  To: ofono

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

---
 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);
 
 	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);
 	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);
 
 	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);
 	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)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2015-02-12 19:04 UTC (permalink / raw)
  To: ofono

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
  2015-02-13 12:23 [PATCH 0/2] SMS-DELIVER TP-OA Alphanum decoding and encoding fix Tommi Kenakkala
@ 2015-02-13 12:23 ` Tommi Kenakkala
  0 siblings, 0 replies; 5+ messages in thread
From: Tommi Kenakkala @ 2015-02-13 12:23 UTC (permalink / raw)
  To: ofono

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

---
 unit/test-sms.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/unit/test-sms.c b/unit/test-sms.c
index 7b644df..259594e 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";
 
@@ -362,6 +368,38 @@ 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);
+
+	ret = sms_decode(decoded_pdu, pdu_len, FALSE, 149, &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 == 149);
+	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)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
@ 2015-02-13 12:47 Tommi Kenakkala
  2015-02-13 16:02 ` Denis Kenzior
  0 siblings, 1 reply; 5+ messages in thread
From: Tommi Kenakkala @ 2015-02-13 12:47 UTC (permalink / raw)
  To: ofono

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

---
 unit/test-sms.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/unit/test-sms.c b/unit/test-sms.c
index 7b644df..259594e 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";
 
@@ -362,6 +368,38 @@ 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);
+
+	ret = sms_decode(decoded_pdu, pdu_len, FALSE, 149, &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 == 149);
+	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)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address
  2015-02-13 12:47 [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address Tommi Kenakkala
@ 2015-02-13 16:02 ` Denis Kenzior
  0 siblings, 0 replies; 5+ messages in thread
From: Denis Kenzior @ 2015-02-13 16:02 UTC (permalink / raw)
  To: ofono

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

Hi Tommi,

On 02/13/2015 06:47 AM, Tommi Kenakkala wrote:
> ---
>   unit/test-sms.c |   38 ++++++++++++++++++++++++++++++++++++++
>   1 file changed, 38 insertions(+)
>

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-13 16:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13 12:47 [PATCH 2/2] unit: SMS-DELIVER decoding/encoding test for long alphanum address Tommi Kenakkala
2015-02-13 16:02 ` Denis Kenzior
  -- 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-12 15:09 [PATCH 0/2] SMS-DELIVER Alphanum TP-OA encoding/decoding fix Tommi Kenakkala
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 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.