aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/utils')
-rw-r--r--tests/utils/utils_test.c7
-rw-r--r--tests/utils/utils_test.ok14
2 files changed, 21 insertions, 0 deletions
diff --git a/tests/utils/utils_test.c b/tests/utils/utils_test.c
index e87cb22f..e15cf5f6 100644
--- a/tests/utils/utils_test.c
+++ b/tests/utils/utils_test.c
@@ -487,6 +487,7 @@ static void bcd2str_test(void)
{
int i;
uint8_t bcd[64];
+ uint8_t bcd2[64];
int rc;
printf("\nTesting bcd to string conversion\n");
@@ -511,6 +512,12 @@ static void bcd2str_test(void)
printf(" ERROR: expected rc=%d\n", t->expect_rc);
if (strcmp(str, t->expect_str))
printf(" ERROR: expected result %s\n", osmo_quote_str(t->expect_str, -1));
+
+ memset(bcd2, 0xff, sizeof(bcd2));
+ rc = osmo_str2bcd(bcd2, sizeof(bcd2), str, t->start_nibble, -1, t->allow_hex);
+ printf("osmo_str2bcd(start_nibble=%d) -> rc=%d\n", t->start_nibble, rc);
+ if (rc > 0)
+ printf(" = %s\n", osmo_hexdump(bcd2, rc));
}
printf("- zero output buffer\n");
diff --git a/tests/utils/utils_test.ok b/tests/utils/utils_test.ok
index baa708ee..cbab72a9 100644
--- a/tests/utils/utils_test.ok
+++ b/tests/utils/utils_test.ok
@@ -181,27 +181,41 @@ Testing bcd to string conversion
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..11[ str_size=64
rc=10
-> "1234567890"
+osmo_str2bcd(start_nibble=1) -> rc=6
+ = 1f 32 54 76 98 f0
- BCD-input='1a 32 a4 cb 9d f0' nibbles=[1..11[ str_size=64
rc=-22
-> "1234ABCD90"
+osmo_str2bcd(start_nibble=1) -> rc=-22
- BCD-input='1a 32 a4 cb 9d f0' nibbles=[1..11[ str_size=64
rc=10
-> "1234ABCD90"
+osmo_str2bcd(start_nibble=1) -> rc=6
+ = 1f 32 a4 cb 9d f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=64
rc=-22
-> "1234567890F"
+osmo_str2bcd(start_nibble=1) -> rc=-22
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=64
rc=11
-> "1234567890F"
+osmo_str2bcd(start_nibble=1) -> rc=6
+ = 1f 32 54 76 98 f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[0..12[ str_size=64
rc=12
-> "A1234567890F"
+osmo_str2bcd(start_nibble=0) -> rc=6
+ = 1a 32 54 76 98 f0
- BCD-input='1a 32 54 76 98 f0' nibbles=[1..12[ str_size=5
rc=11
-> "1234"
+osmo_str2bcd(start_nibble=1) -> rc=3
+ = 1f 32 f4
- BCD-input='' nibbles=[1..1[ str_size=64
rc=0
-> ""
+osmo_str2bcd(start_nibble=1) -> rc=1
+ = ff
- zero output buffer
bcd2str(NULL, ...) -> -12
bcd2str(dst, 0, ...) -> -12