summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/sms/sms_test.c22
-rw-r--r--tests/sms/sms_test.ok8
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/sms/sms_test.c b/tests/sms/sms_test.c
index 2c9d8d8b..755b3213 100644
--- a/tests/sms/sms_test.c
+++ b/tests/sms/sms_test.c
@@ -280,6 +280,17 @@ int main(int argc, char** argv)
/* test 7-bit encoding */
for (i = 0; i < ARRAY_SIZE(test_encode); ++i) {
+ /* Test legacy function (return value only) */
+ septet_length = gsm_7bit_encode(coded,
+ (const char *) test_encode[i].input);
+ printf("Legacy encode case %d: "
+ "septet length %d (expected %d)\n"
+ , i
+ , septet_length, test_encode[i].expected_septet_length
+ );
+ OSMO_ASSERT (septet_length == test_encode[i].expected_septet_length);
+
+ /* Test new function */
memset(coded, 0x42, sizeof(coded));
septet_length = gsm_7bit_encode_n(coded, sizeof(coded),
(const char *) test_encode[i].input,
@@ -296,6 +307,7 @@ int main(int argc, char** argv)
OSMO_ASSERT (octets_written == test_encode[i].expected_octet_length);
OSMO_ASSERT (octets_written == computed_octet_length);
OSMO_ASSERT (memcmp(coded, test_encode[i].expected, octets_written) == 0);
+ OSMO_ASSERT (septet_length == test_encode[i].expected_septet_length);
/* check buffer limiting */
memset(coded, 0xaa, sizeof(coded));
@@ -357,6 +369,16 @@ int main(int argc, char** argv)
/* test 7-bit decoding */
for (i = 0; i < ARRAY_SIZE(test_decode); ++i) {
+ /* Test legacy function (return value only) */
+ if (!test_decode[i].ud_hdr_ind) {
+ nchars = gsm_7bit_decode(result, test_decode[i].input,
+ test_decode[i].expected_septet_length);
+ printf("Legacy decode case %d: "
+ "return value %d (expected %d)\n",
+ i, nchars, test_decode[i].expected_septet_length);
+ }
+
+ /* Test new function */
memset(result, 0x42, sizeof(result));
nchars = gsm_7bit_decode_n_hdr(result, sizeof(result), test_decode[i].input,
test_decode[i].expected_septet_length, test_decode[i].ud_hdr_ind);
diff --git a/tests/sms/sms_test.ok b/tests/sms/sms_test.ok
index a71567de..fa536eaa 100644
--- a/tests/sms/sms_test.ok
+++ b/tests/sms/sms_test.ok
@@ -1,11 +1,19 @@
SMS testing
+Legacy encode case 0: septet length 9 (expected 9)
Encode case 0: Octet length 8 (expected 8, computed 8), septet length 9 (expected 9)
+Legacy encode case 1: septet length 41 (expected 41)
Encode case 1: Octet length 36 (expected 36, computed 36), septet length 41 (expected 41)
+Legacy encode case 2: septet length 39 (expected 39)
Encode case 2: Octet length 35 (expected 35, computed 35), septet length 39 (expected 39)
+Legacy encode case 3: septet length 40 (expected 40)
Encode case 3: Octet length 35 (expected 35, computed 35), septet length 40 (expected 40)
+Legacy decode case 0: return value 9 (expected 9)
Decode case 0: return value 9 (expected 9)
+Legacy decode case 1: return value 41 (expected 41)
Decode case 1: return value 40 (expected 40)
+Legacy decode case 2: return value 39 (expected 39)
Decode case 2: return value 31 (expected 31)
+Legacy decode case 3: return value 40 (expected 40)
Decode case 3: return value 32 (expected 32)
Decode case 4: return value 153 (expected 153)
Decode case 5: return value 40 (expected 40)