* [PATCH] SMS character set unit tests.
@ 2010-12-01 12:27 Oleg Zhurakivskyy
2010-12-08 16:31 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Oleg Zhurakivskyy @ 2010-12-01 12:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10093 bytes --]
---
unit/test-sms.c | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 244 insertions(+), 0 deletions(-)
diff --git a/unit/test-sms.c b/unit/test-sms.c
index c8a9d9c..a7aa3da 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -471,6 +471,222 @@ static void test_submit_encode()
g_free(encoded_pdu);
}
+struct sms_charset_data {
+ gchar *pdu;
+ gint data_len;
+ enum gsm_dialect locking_lang;
+ enum gsm_dialect single_lang;
+ gchar expected_text[];
+};
+
+static struct sms_charset_data sms_charset_default = {
+ .pdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF",
+ .data_len = 112,
+ .expected_text = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xc3, 0xa8, 0xc3, 0xa9,
+ 0xc3, 0xb9, 0xc3, 0xac, 0xc3, 0xb2, 0xc3, 0x87, 0x0a, 0xc3,
+ 0x98, 0xc3, 0xb8, 0x0d, 0xc3, 0x85, 0xc3, 0xa5, 0xce, 0x94,
+ 0x5f, 0xce, 0xa6, 0xce, 0x93, 0xce, 0x9b, 0xce, 0xa9, 0xce,
+ 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xce, 0x9e, 0x20,
+ 0xc3, 0x86, 0xc3, 0xa6, 0xc3, 0x9f, 0xc3, 0x89, 0x20, 0x21,
+ 0x22, 0x23, 0xc2, 0xa4, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
+ 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
+ 0x3f, 0xc2, 0xa1, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
+ 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xc3,
+ 0x84, 0xc3, 0x96, 0xc3, 0x91, 0xc3, 0x9c, 0xc2, 0xa7, 0xc2,
+ 0xbf, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa4, 0xc3,
+ 0xb6, 0xc3, 0xb1, 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_default_ext = {
+ .pdu =
+ "0001000B91" "5310101010" "100000151B" "C58602DAA0" "36A9CD6BC3"
+ "DBF436BE0D" "705306",
+ .data_len = 19,
+ .expected_text = {
+ 0x0c, 0x5e, 0x20, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c,
+ 0xe2, 0x82, 0xac, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_turkey = {
+ .pdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF",
+ .data_len = 112,
+ .locking_lang = GSM_DIALECT_TURKISH,
+ .expected_text = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xe2, 0x82, 0xac, 0xc3,
+ 0xa9, 0xc3, 0xb9, 0xc4, 0xb1, 0xc3, 0xb2, 0xc3, 0x87, 0x0a,
+ 0xc4, 0x9e, 0xc4, 0x9f, 0x0d, 0xc3, 0x85, 0xc3, 0xa5, 0xce,
+ 0x94, 0x5f, 0xce, 0xa6, 0xce, 0x93, 0xce, 0x9b, 0xce, 0xa9,
+ 0xce, 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xce, 0x9e,
+ 0x20, 0xc5, 0x9e, 0xc5, 0x9f, 0xc3, 0x9f, 0xc3, 0x89, 0x20,
+ 0x21, 0x22, 0x23, 0xc2, 0xa4, 0x25, 0x26, 0x27, 0x28, 0x29,
+ 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d,
+ 0x3e, 0x3f, 0xc4, 0xb0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
+ 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
+ 0xc3, 0x84, 0xc3, 0x96, 0xc3, 0x91, 0xc3, 0x9c, 0xc2, 0xa7,
+ 0xc3, 0xa7, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa4,
+ 0xc3, 0xb6, 0xc3, 0xb1, 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_turkey_ext = {
+ .pdu =
+ "0001000B91" "5310101010" "1000001A1B" "C586B2416D" "529BD786B7"
+ "E96D7C1BE0" "02C8011318" "870E",
+ .data_len = 23,
+ .locking_lang = GSM_DIALECT_TURKISH,
+ .single_lang = GSM_DIALECT_TURKISH,
+ .expected_text = {
+ 0x0c, 0x5e, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c, 0xc4,
+ 0x9e, 0xc4, 0xb0, 0xc5, 0x9e, 0xc3, 0xa7, 0xe2, 0x82, 0xac,
+ 0xc4, 0x9f, 0xc4, 0xb1, 0xc5, 0x9f, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_portugal = {
+ .pdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF",
+ .data_len = 112,
+ .locking_lang = GSM_DIALECT_PORTUGUESE,
+ .expected_text = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xc3, 0xaa, 0xc3, 0xa9,
+ 0xc3, 0xba, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xa7, 0x0a, 0xc3,
+ 0x94, 0xc3, 0xb4, 0x0d, 0xc3, 0x81, 0xc3, 0xa1, 0xce, 0x94,
+ 0x5f, 0xc2, 0xaa, 0xc3, 0x87, 0xc3, 0x80, 0xe2, 0x88, 0x9e,
+ 0x5e, 0x5c, 0xe2, 0x82, 0xac, 0xc3, 0x93, 0x7c, 0x20, 0xc3,
+ 0x82, 0xc3, 0xa2, 0xc3, 0x8a, 0xc3, 0x89, 0x20, 0x21, 0x22,
+ 0x23, 0xc2, 0xba, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+ 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0xc3, 0x8d, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52,
+ 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xc3, 0x83,
+ 0xc3, 0x95, 0xc3, 0x9a, 0xc3, 0x9c, 0xc2, 0xa7, 0x7e, 0x61,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
+ 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa3, 0xc3, 0xb5, 0x60,
+ 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_portugal_ext = {
+ .pdu =
+ "0001000B91" "5310101010" "1000003184" "C446B16038" "1E1BC96662"
+ "D9543696CD" "6583D9643C" "1BD42675D9" "F0C01B9F86" "02CC74B75C"
+ "0EE68030EC" "F91D",
+ .data_len = 43,
+ .locking_lang = GSM_DIALECT_PORTUGUESE,
+ .single_lang = GSM_DIALECT_PORTUGUESE,
+ .expected_text = {
+ 0xc3, 0xaa, 0xc3, 0xa7, 0x0c, 0xc3, 0x94, 0xc3, 0xb4, 0xc3,
+ 0x81, 0xc3, 0xa1, 0xce, 0xa6, 0xce, 0x93, 0x5e, 0xce, 0xa9,
+ 0xce, 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xc3, 0x8a,
+ 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c, 0xc3, 0x80, 0xc3,
+ 0x8d, 0xc3, 0x93, 0xc3, 0x9a, 0xc3, 0x83, 0xc3, 0x95, 0xc3,
+ 0x82, 0xe2, 0x82, 0xac, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba,
+ 0xc3, 0xa3, 0xc3, 0xb5, 0xc3, 0xa2, 0x00
+ }
+};
+
+static struct sms_charset_data sms_charset_spain = {
+ .pdu =
+ "0001000B91" "5310101010" "100000269B" "C446B1A16C" "509BD4E6B5"
+ "E16D7A1BDF" "06B8096E92" "9BE7A6BA09" "6FCA9BF4E6" "BDA903",
+ .data_len = 34,
+ .locking_lang = GSM_DIALECT_SPANISH,
+ .single_lang = GSM_DIALECT_SPANISH,
+ .expected_text = {
+ 0xc3, 0xa7, 0x0c, 0x5e, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d,
+ 0x7c, 0xc3, 0x81, 0xc3, 0x8d, 0xc3, 0x93, 0xc3, 0x9a, 0xc3,
+ 0xa1, 0xe2, 0x82, 0xac, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba,
+ 0x00
+ }
+};
+
+static void test_sms_charset(gconstpointer param)
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu;
+ guint8 *unpacked;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *text;
+ struct sms_charset_data *data = (struct sms_charset_data *)param;
+
+ pdu = decode_hex(data->pdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(data->pdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == data->data_len);
+
+ unpacked = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+
+ g_assert(unpacked);
+
+ text = convert_gsm_to_utf8_with_lang(unpacked, -1, NULL, NULL, 0xff,
+ data->locking_lang, data->single_lang);
+
+ g_assert(text);
+
+ g_free(unpacked);
+
+ g_assert(strcmp(data->expected_text, text) == 0);
+
+ g_free(text);
+}
+
struct text_format_header {
unsigned char len;
unsigned char start;
@@ -1461,6 +1677,34 @@ int main(int argc, char **argv)
g_test_add_func("/testsms/Test Simple Submit", test_simple_submit);
g_test_add_func("/testsms/Test Submit Encode", test_submit_encode);
+ g_test_add_data_func("/testsms/Test "
+ "GSM 7 bit Default Alphabet Decode",
+ &sms_charset_default, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "GSM 7 bit Default Alphabet Extension Table Decode",
+ &sms_charset_default_ext, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "Turkish National Language Locking Shift Table Decode",
+ &sms_charset_turkey, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "Turkish National Language Single Shift Table Decode",
+ &sms_charset_turkey_ext, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "Portuguese National Language Locking Shift Table Decode",
+ &sms_charset_portugal, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "Portuguese National Language Single Shift Table Decode",
+ &sms_charset_portugal_ext, test_sms_charset);
+
+ g_test_add_data_func("/testsms/Test "
+ "Spanish National Language Single Shift Table Decode",
+ &sms_charset_spain, test_sms_charset);
+
g_test_add_data_func("/testsms/Test EMS UDH 1",
&ems_udh_test_1, test_ems_udh);
g_test_add_data_func("/testsms/Test EMS UDH 2",
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] SMS character set unit tests.
@ 2010-11-23 15:21 Oleg Zhurakivskyy
2010-11-23 16:21 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Oleg Zhurakivskyy @ 2010-11-23 15:21 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 15910 bytes --]
---
unit/test-sms.c | 506 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 506 insertions(+), 0 deletions(-)
diff --git a/unit/test-sms.c b/unit/test-sms.c
index c8a9d9c..426d7d3 100644
--- a/unit/test-sms.c
+++ b/unit/test-sms.c
@@ -471,6 +471,488 @@ static void test_submit_encode()
g_free(encoded_pdu);
}
+static void test_charset_default_alphabet_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF";
+ gchar *text, expected_text[] = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xc3, 0xa8, 0xc3, 0xa9,
+ 0xc3, 0xb9, 0xc3, 0xac, 0xc3, 0xb2, 0xc3, 0x87, 0x0a, 0xc3,
+ 0x98, 0xc3, 0xb8, 0x0d, 0xc3, 0x85, 0xc3, 0xa5, 0xce, 0x94,
+ 0x5f, 0xce, 0xa6, 0xce, 0x93, 0xce, 0x9b, 0xce, 0xa9, 0xce,
+ 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xce, 0x9e, 0x20,
+ 0xc3, 0x86, 0xc3, 0xa6, 0xc3, 0x9f, 0xc3, 0x89, 0x20, 0x21,
+ 0x22, 0x23, 0xc2, 0xa4, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
+ 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
+ 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
+ 0x3f, 0xc2, 0xa1, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+ 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
+ 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xc3,
+ 0x84, 0xc3, 0x96, 0xc3, 0x91, 0xc3, 0x9c, 0xc2, 0xa7, 0xc2,
+ 0xbf, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
+ 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa4, 0xc3,
+ 0xb6, 0xc3, 0xb1, 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ g_assert(sms.deliver.udl == 128);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 112);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8(data, -1, NULL, NULL, 0xff);
+
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_default_alphabet_ext_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "100000151B" "C58602DAA0" "36A9CD6BC3"
+ "DBF436BE0D" "705306";
+ gchar *text, expected_text[] = {
+ 0x0c, 0x5e, 0x20, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c,
+ 0xe2, 0x82, 0xac, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ g_assert(sms.deliver.udl == 21);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 19);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8(data, -1, NULL, NULL, 0xff);
+
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_turkey_locking_shift_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF";
+ gchar *text, expected_text[] = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xe2, 0x82, 0xac, 0xc3,
+ 0xa9, 0xc3, 0xb9, 0xc4, 0xb1, 0xc3, 0xb2, 0xc3, 0x87, 0x0a,
+ 0xc4, 0x9e, 0xc4, 0x9f, 0x0d, 0xc3, 0x85, 0xc3, 0xa5, 0xce,
+ 0x94, 0x5f, 0xce, 0xa6, 0xce, 0x93, 0xce, 0x9b, 0xce, 0xa9,
+ 0xce, 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xce, 0x9e,
+ 0x20, 0xc5, 0x9e, 0xc5, 0x9f, 0xc3, 0x9f, 0xc3, 0x89, 0x20,
+ 0x21, 0x22, 0x23, 0xc2, 0xa4, 0x25, 0x26, 0x27, 0x28, 0x29,
+ 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
+ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d,
+ 0x3e, 0x3f, 0xc4, 0xb0, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
+ 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
+ 0xc3, 0x84, 0xc3, 0x96, 0xc3, 0x91, 0xc3, 0x9c, 0xc2, 0xa7,
+ 0xc3, 0xa7, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
+ 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
+ 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa4,
+ 0xc3, 0xb6, 0xc3, 0xb1, 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 112);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+
+ g_assert(data);
+
+ text = convert_gsm_to_utf8_with_lang(data, -1, NULL, NULL, 0xff,
+ GSM_DIALECT_TURKISH,
+ GSM_DIALECT_DEFAULT);
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_turkey_ext_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "1000001A1B" "C586B2416D" "529BD786B7"
+ "E96D7C1BE0" "02C8011318" "870E";
+ gchar *text, expected_text[] = {
+ 0x0c, 0x5e, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c, 0xc4,
+ 0x9e, 0xc4, 0xb0, 0xc5, 0x9e, 0xc3, 0xa7, 0xe2, 0x82, 0xac,
+ 0xc4, 0x9f, 0xc4, 0xb1, 0xc5, 0x9f, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 23);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8_with_lang(data, -1, NULL, NULL, 0xff,
+ GSM_DIALECT_TURKISH,
+ GSM_DIALECT_TURKISH);
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_portugal_locking_shift_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
+ "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
+ "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
+ "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
+ "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
+ "FF";
+ gchar *text, expected_text[] = {
+ 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xc3, 0xaa, 0xc3, 0xa9,
+ 0xc3, 0xba, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xa7, 0x0a, 0xc3,
+ 0x94, 0xc3, 0xb4, 0x0d, 0xc3, 0x81, 0xc3, 0xa1, 0xce, 0x94,
+ 0x5f, 0xc2, 0xaa, 0xc3, 0x87, 0xc3, 0x80, 0xe2, 0x88, 0x9e,
+ 0x5e, 0x5c, 0xe2, 0x82, 0xac, 0xc3, 0x93, 0x7c, 0x20, 0xc3,
+ 0x82, 0xc3, 0xa2, 0xc3, 0x8a, 0xc3, 0x89, 0x20, 0x21, 0x22,
+ 0x23, 0xc2, 0xba, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+ 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
+ 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0xc3, 0x8d, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52,
+ 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xc3, 0x83,
+ 0xc3, 0x95, 0xc3, 0x9a, 0xc3, 0x9c, 0xc2, 0xa7, 0x7e, 0x61,
+ 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
+ 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
+ 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa3, 0xc3, 0xb5, 0x60,
+ 0xc3, 0xbc, 0xc3, 0xa0, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 112);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8_with_lang(data, -1, NULL, NULL, 0xff,
+ GSM_DIALECT_PORTUGUESE,
+ GSM_DIALECT_DEFAULT);
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_portugal_ext_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "1000003184" "C446B16038" "1E1BC96662"
+ "D9543696CD" "6583D9643C" "1BD42675D9" "F0C01B9F86" "02CC74B75C"
+ "0EE68030EC" "F91D";
+ gchar *text, expected_text[] = {
+ 0xc3, 0xaa, 0xc3, 0xa7, 0x0c, 0xc3, 0x94, 0xc3, 0xb4, 0xc3,
+ 0x81, 0xc3, 0xa1, 0xce, 0xa6, 0xce, 0x93, 0x5e, 0xce, 0xa9,
+ 0xce, 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xc3, 0x8a,
+ 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d, 0x7c, 0xc3, 0x80, 0xc3,
+ 0x8d, 0xc3, 0x93, 0xc3, 0x9a, 0xc3, 0x83, 0xc3, 0x95, 0xc3,
+ 0x82, 0xe2, 0x82, 0xac, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba,
+ 0xc3, 0xa3, 0xc3, 0xb5, 0xc3, 0xa2, 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 43);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8_with_lang(data, -1, NULL, NULL, 0xff,
+ GSM_DIALECT_PORTUGUESE,
+ GSM_DIALECT_PORTUGUESE);
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
+static void test_charset_spain_decode()
+{
+ gboolean ret;
+ struct sms sms;
+ guint8 *pdu, *data;
+ gint64 pdu_len;
+ gint data_len;
+ enum sms_charset sms_charset;
+ gboolean sms_compressed;
+ gchar *spdu =
+ "0001000B91" "5310101010" "100000269B" "C446B1A16C" "509BD4E6B5"
+ "E16D7A1BDF" "06B8096E92" "9BE7A6BA09" "6FCA9BF4E6" "BDA903";
+ gchar *text, expected_text[] = {
+ 0xc3, 0xa7, 0x0c, 0x5e, 0x7b, 0x7d, 0x5c, 0x5b, 0x7e, 0x5d,
+ 0x7c, 0xc3, 0x81, 0xc3, 0x8d, 0xc3, 0x93, 0xc3, 0x9a, 0xc3,
+ 0xa1, 0xe2, 0x82, 0xac, 0xc3, 0xad, 0xc3, 0xb3, 0xc3, 0xba,
+ 0x00
+ };
+
+ pdu = decode_hex(spdu, -1, &pdu_len, 0);
+
+ g_assert(pdu);
+
+ g_assert(pdu_len == (gint64)strlen(spdu) / 2);
+
+ ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
+
+ g_assert(ret);
+
+ g_free(pdu);
+
+ g_assert(sms.type == SMS_TYPE_DELIVER);
+
+ ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
+ &sms_compressed, NULL);
+ g_assert(ret);
+
+ g_assert(sms_charset == SMS_CHARSET_7BIT);
+
+ g_assert(sms_compressed == FALSE);
+
+ data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
+
+ g_assert(data_len == 34);
+
+ data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
+ sms.deliver.udl, NULL, 0xff);
+ g_assert(data);
+
+ text = convert_gsm_to_utf8_with_lang(data, -1, NULL, NULL, 0xff,
+ GSM_DIALECT_SPANISH,
+ GSM_DIALECT_SPANISH);
+ g_assert(text);
+
+ g_free(data);
+
+ g_assert(strcmp(expected_text, text) == 0);
+
+ g_free(text);
+}
+
struct text_format_header {
unsigned char len;
unsigned char start;
@@ -1461,6 +1943,30 @@ int main(int argc, char **argv)
g_test_add_func("/testsms/Test Simple Submit", test_simple_submit);
g_test_add_func("/testsms/Test Submit Encode", test_submit_encode);
+ g_test_add_func("/testsms/Test "
+ "GSM 7 bit Default Alphabet Decode",
+ test_charset_default_alphabet_decode);
+ g_test_add_func("/testsms/Test "
+ "GSM 7 bit Default Alphabet Extension Table Decode",
+ test_charset_default_alphabet_ext_decode);
+ g_test_add_func("/testsms/Test "
+ "Turkish National Language Locking Shift Table Decode",
+ test_charset_turkey_locking_shift_decode);
+ g_test_add_func("/testsms/Test "
+ "Turkish National Language Single Shift Table Decode",
+ test_charset_turkey_ext_decode);
+ g_test_add_func("/testsms/Test "
+ "Portuguese National Language Locking Shift "
+ "Table Decode",
+ test_charset_portugal_locking_shift_decode);
+ g_test_add_func("/testsms/Test "
+ "Portuguese National Language Single Shift "
+ "Table Decode",
+ test_charset_portugal_ext_decode);
+ g_test_add_func("/testsms/Test "
+ "Spanish National Language Single Shift Table Decode",
+ test_charset_spain_decode);
+
g_test_add_data_func("/testsms/Test EMS UDH 1",
&ems_udh_test_1, test_ems_udh);
g_test_add_data_func("/testsms/Test EMS UDH 2",
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] SMS character set unit tests.
2010-11-23 15:21 Oleg Zhurakivskyy
@ 2010-11-23 16:21 ` Denis Kenzior
0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2010-11-23 16:21 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5094 bytes --]
Hi Oleg,
On 11/23/2010 09:21 AM, Oleg Zhurakivskyy wrote:
> ---
> unit/test-sms.c | 506 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 506 insertions(+), 0 deletions(-)
>
> diff --git a/unit/test-sms.c b/unit/test-sms.c
> index c8a9d9c..426d7d3 100644
> --- a/unit/test-sms.c
> +++ b/unit/test-sms.c
> @@ -471,6 +471,488 @@ static void test_submit_encode()
> g_free(encoded_pdu);
> }
>
> +static void test_charset_default_alphabet_decode()
> +{
> + gboolean ret;
> + struct sms sms;
> + guint8 *pdu, *data;
> + gint64 pdu_len;
> + gint data_len;
> + enum sms_charset sms_charset;
> + gboolean sms_compressed;
> + gchar *spdu =
> + "0001000B91" "5310101010" "1000008080" "8060402818" "0E888462C1"
> + "68381E9088" "6442A9582E" "988C06C4E9" "783EA09068" "442A994EA8"
> + "946AC56AB9" "5EB0986C46" "ABD96EB89C" "6EC7EBF97E" "C0A070482C"
> + "1A8FC8A472" "C96C3A9FD0" "A8744AAD5A" "AFD8AC76CB" "ED7ABFE0B0"
> + "784C2E9BCF" "E8B47ACD6E" "BBDFF0B87C" "4EAFDBEFF8" "BC7ECFEFFB"
> + "FF";
> + gchar *text, expected_text[] = {
> + 0x40, 0xc2, 0xa3, 0x24, 0xc2, 0xa5, 0xc3, 0xa8, 0xc3, 0xa9,
> + 0xc3, 0xb9, 0xc3, 0xac, 0xc3, 0xb2, 0xc3, 0x87, 0x0a, 0xc3,
> + 0x98, 0xc3, 0xb8, 0x0d, 0xc3, 0x85, 0xc3, 0xa5, 0xce, 0x94,
> + 0x5f, 0xce, 0xa6, 0xce, 0x93, 0xce, 0x9b, 0xce, 0xa9, 0xce,
> + 0xa0, 0xce, 0xa8, 0xce, 0xa3, 0xce, 0x98, 0xce, 0x9e, 0x20,
> + 0xc3, 0x86, 0xc3, 0xa6, 0xc3, 0x9f, 0xc3, 0x89, 0x20, 0x21,
> + 0x22, 0x23, 0xc2, 0xa4, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a,
> + 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34,
> + 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
> + 0x3f, 0xc2, 0xa1, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
> + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
> + 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xc3,
> + 0x84, 0xc3, 0x96, 0xc3, 0x91, 0xc3, 0x9c, 0xc2, 0xa7, 0xc2,
> + 0xbf, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
> + 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
> + 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0xc3, 0xa4, 0xc3,
> + 0xb6, 0xc3, 0xb1, 0xc3, 0xbc, 0xc3, 0xa0, 0x00
> + };
> +
> + pdu = decode_hex(spdu, -1, &pdu_len, 0);
> +
> + g_assert(pdu);
> +
> + g_assert(pdu_len == (gint64)strlen(spdu) / 2);
> +
> + ret = sms_decode(pdu, pdu_len, FALSE, pdu_len, &sms);
> +
> + g_assert(ret);
> +
> + g_free(pdu);
> +
> + g_assert(sms.type == SMS_TYPE_DELIVER);
> +
> + ret = sms_dcs_decode(sms.deliver.dcs, NULL, &sms_charset,
> + &sms_compressed, NULL);
Just a minor nitpick, but please don't mix tabs and spaces for
indentation. Stick to tabs.
> + g_assert(ret);
> +
> + g_assert(sms_charset == SMS_CHARSET_7BIT);
> +
> + g_assert(sms_compressed == FALSE);
> +
> + g_assert(sms.deliver.udl == 128);
> +
> + data_len = sms_udl_in_bytes(sms.deliver.udl, sms.deliver.dcs);
> +
> + g_assert(data_len == 112);
> +
> + data = unpack_7bit(sms.deliver.ud, data_len, 0, FALSE,
> + sms.deliver.udl, NULL, 0xff);
> + g_assert(data);
> +
> + text = convert_gsm_to_utf8(data, -1, NULL, NULL, 0xff);
> +
> + g_assert(text);
> +
> + g_free(data);
> +
> + g_assert(strcmp(expected_text, text) == 0);
> +
> + g_free(text);
> +}
> +
<snip>
> struct text_format_header {
> unsigned char len;
> unsigned char start;
> @@ -1461,6 +1943,30 @@ int main(int argc, char **argv)
> g_test_add_func("/testsms/Test Simple Submit", test_simple_submit);
> g_test_add_func("/testsms/Test Submit Encode", test_submit_encode);
>
> + g_test_add_func("/testsms/Test "
> + "GSM 7 bit Default Alphabet Decode",
> + test_charset_default_alphabet_decode);
> + g_test_add_func("/testsms/Test "
> + "GSM 7 bit Default Alphabet Extension Table Decode",
> + test_charset_default_alphabet_ext_decode);
> + g_test_add_func("/testsms/Test "
> + "Turkish National Language Locking Shift Table Decode",
> + test_charset_turkey_locking_shift_decode);
> + g_test_add_func("/testsms/Test "
> + "Turkish National Language Single Shift Table Decode",
> + test_charset_turkey_ext_decode);
> + g_test_add_func("/testsms/Test "
> + "Portuguese National Language Locking Shift "
> + "Table Decode",
> + test_charset_portugal_locking_shift_decode);
> + g_test_add_func("/testsms/Test "
> + "Portuguese National Language Single Shift "
> + "Table Decode",
> + test_charset_portugal_ext_decode);
> + g_test_add_func("/testsms/Test "
> + "Spanish National Language Single Shift Table Decode",
> + test_charset_spain_decode);
> +
So these functions are nearly identical except for the input data and
the expected result. So instead of using g_test_add_func I suggest you
use g_test_add_data_func and create a data structure to hold the test.
Please see unit/test-stkutil.c for _lots_ of great examples ;)
> g_test_add_data_func("/testsms/Test EMS UDH 1",
> &ems_udh_test_1, test_ems_udh);
> g_test_add_data_func("/testsms/Test EMS UDH 2",
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-12-08 16:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01 12:27 [PATCH] SMS character set unit tests Oleg Zhurakivskyy
2010-12-08 16:31 ` Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2010-11-23 15:21 Oleg Zhurakivskyy
2010-11-23 16:21 ` 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.