tests: add a test for 25-character SMS messages
Tests that the last septet (packed in an octet by itself) doesn't get left off the message like the old code used to do before "core: fix some bugs in GSM7 packing code".
This commit is contained in:
@@ -572,6 +572,34 @@ test_create_pdu_gsm_no_smsc (void *f, gpointer d)
|
|||||||
g_assert_cmpint (memcmp (pdu, expected, len), ==, 0);
|
g_assert_cmpint (memcmp (pdu, expected, len), ==, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_create_pdu_gsm_3 (void *f, gpointer d)
|
||||||
|
{
|
||||||
|
static const char *number = "+15556661234";
|
||||||
|
static const char *text = "This is really cool ΔΔΔΔΔ";
|
||||||
|
static const guint8 expected[] = {
|
||||||
|
0x00, 0x11, 0x00, 0x0B, 0x91, 0x51, 0x55, 0x66, 0x16, 0x32, 0xF4, 0x00,
|
||||||
|
0x00, 0x00, 0x19, 0x54, 0x74, 0x7A, 0x0E, 0x4A, 0xCF, 0x41, 0xF2, 0x72,
|
||||||
|
0x98, 0xCD, 0xCE, 0x83, 0xC6, 0xEF, 0x37, 0x1B, 0x04, 0x81, 0x40, 0x20,
|
||||||
|
0x10
|
||||||
|
};
|
||||||
|
guint8 *pdu;
|
||||||
|
guint len = 0;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
/* Tests that a 25-character message (where the last septet is packed into
|
||||||
|
* an octet by itself) is created correctly. Previous to
|
||||||
|
* "core: fix some bugs in GSM7 packing code" the GSM packing code would
|
||||||
|
* leave off the last octet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
pdu = sms_create_submit_pdu (number, text, NULL, 1, 0, &len, &error);
|
||||||
|
g_assert_no_error (error);
|
||||||
|
g_assert (pdu);
|
||||||
|
g_assert_cmpint (len, ==, sizeof (expected));
|
||||||
|
g_assert_cmpint (memcmp (pdu, expected, len), ==, 0);
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -626,6 +654,8 @@ int main (int argc, char **argv)
|
|||||||
g_test_suite_add (suite, TESTCASE (test_create_pdu_gsm_with_smsc, NULL));
|
g_test_suite_add (suite, TESTCASE (test_create_pdu_gsm_with_smsc, NULL));
|
||||||
g_test_suite_add (suite, TESTCASE (test_create_pdu_gsm_no_smsc, NULL));
|
g_test_suite_add (suite, TESTCASE (test_create_pdu_gsm_no_smsc, NULL));
|
||||||
|
|
||||||
|
g_test_suite_add (suite, TESTCASE (test_create_pdu_gsm_3, NULL));
|
||||||
|
|
||||||
result = g_test_run ();
|
result = g_test_run ();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user