mirror of git://git.sysmocom.de/ofono
test-sms: Add a unit test for the previous bugfix
This commit is contained in:
parent
4638d3ad83
commit
ff2a3029b3
|
@ -762,16 +762,26 @@ static void test_prepare_7bit()
|
|||
g_slist_free(r);
|
||||
}
|
||||
|
||||
static const char *pad1 = "Shakespeare divided his time between London and Str"
|
||||
struct sms_concat_data {
|
||||
const char *str;
|
||||
unsigned int segments;
|
||||
};
|
||||
|
||||
|
||||
static struct sms_concat_data shakespeare_test = {
|
||||
.str = "Shakespeare divided his time between London and Str"
|
||||
"atford during his career. In 1596, the year before he bought New Plac"
|
||||
"e as his family home in Stratford, Shakespeare was living in the pari"
|
||||
"sh of St. Helen's, Bishopsgate, north of the River Thames.";
|
||||
"sh of St. Helen's, Bishopsgate, north of the River Thames.",
|
||||
.segments = 2,
|
||||
};
|
||||
|
||||
/* The string in this test should be padded at the end. This confuses some
|
||||
* decoders which do not use udl properly
|
||||
*/
|
||||
static void test_prepare_concat()
|
||||
static void test_prepare_concat(gconstpointer data)
|
||||
{
|
||||
const struct sms_concat_data *test = data;
|
||||
GSList *r;
|
||||
GSList *l;
|
||||
char *decoded_str;
|
||||
|
@ -786,12 +796,12 @@ static void test_prepare_concat()
|
|||
guint8 seq;
|
||||
|
||||
if (g_test_verbose())
|
||||
g_print("strlen: %zd\n", strlen(pad1));
|
||||
g_print("strlen: %zd\n", strlen(test->str));
|
||||
|
||||
r = sms_text_prepare(pad1, 0, TRUE, NULL);
|
||||
r = sms_text_prepare(test->str, 0, TRUE, NULL);
|
||||
|
||||
g_assert(r);
|
||||
g_assert(g_slist_length(r) == 2);
|
||||
g_assert(g_slist_length(r) == test->segments);
|
||||
|
||||
for (l = r; l; l = l->next) {
|
||||
char *strpdu;
|
||||
|
@ -842,7 +852,7 @@ static void test_prepare_concat()
|
|||
g_printf("Decoded String: %s\n", decoded_str);
|
||||
|
||||
g_assert(decoded_str);
|
||||
g_assert(strcmp(decoded_str, pad1) == 0);
|
||||
g_assert(strcmp(decoded_str, test->str) == 0);
|
||||
g_free(decoded_str);
|
||||
sms_assembly_free(assembly);
|
||||
}
|
||||
|
@ -1161,6 +1171,9 @@ static void test_range_minimizer()
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char long_string[152*33 + 1];
|
||||
struct sms_concat_data long_string_test;
|
||||
|
||||
g_test_init(&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func("/testsms/Test Simple Deliver", test_simple_deliver);
|
||||
|
@ -1171,7 +1184,22 @@ int main(int argc, char **argv)
|
|||
g_test_add_func("/testsms/Test UDH Iterator", test_udh_iter);
|
||||
g_test_add_func("/testsms/Test Assembly", test_assembly);
|
||||
g_test_add_func("/testsms/Test Prepare 7Bit", test_prepare_7bit);
|
||||
g_test_add_func("/testsms/Test Prepare Concat", test_prepare_concat);
|
||||
|
||||
g_test_add_data_func("/testsms/Test Prepare Concat",
|
||||
&shakespeare_test, test_prepare_concat);
|
||||
|
||||
memset(long_string, 'a', 152*30);
|
||||
memset(long_string + 152*30, 'b', 152);
|
||||
memset(long_string + 152*31, 'c', 152);
|
||||
memset(long_string + 152*32, 'd', 152);
|
||||
long_string[152*33] = '\0';
|
||||
|
||||
long_string_test.str = long_string;
|
||||
long_string_test.segments = 33;
|
||||
|
||||
g_test_add_data_func("/testsms/Test Prepare Concat 30+ segments",
|
||||
&long_string_test, test_prepare_concat);
|
||||
|
||||
g_test_add_func("/testsms/Test Prepare Limits", test_prepare_limits);
|
||||
|
||||
g_test_add_func("/testsms/Test CBS Encode / Decode",
|
||||
|
|
Loading…
Reference in New Issue