aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2015-11-23 15:48:59 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2015-11-23 15:48:59 +0100
commitec0e50e1481a8905ba0998fc07fd62b8ac2acfb0 (patch)
tree037b6133902ede7ccf3c4fd1220bc5c2f2c69d05 /src
parent6e59d413a2c49ecf4e14fef555b1ba344d744dd7 (diff)
tests: Test asn1_strncpy function
Diffstat (limited to 'src')
-rw-r--r--src/tests/test-helpers.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/tests/test-helpers.c b/src/tests/test-helpers.c
index b82e909..717554d 100644
--- a/src/tests/test-helpers.c
+++ b/src/tests/test-helpers.c
@@ -57,10 +57,18 @@ void test_iu_helpers(void)
uint32_t val1 = 0xdeadbeef;
+const OCTET_STRING_t text1 = {
+ .buf = "0123456789012345",
+ .size = 16,
+};
+
void test_asn1_helpers(void)
{
+ int rc;
+
BIT_STRING_t enc;
uint32_t res;
+ char text[32];
printf("Testing asn.1 helper functions\n");
@@ -76,6 +84,13 @@ void test_asn1_helpers(void)
printf("Decoding back to uint32_t: 0x%x\n", res);
ASSERT(res == val1);
+
+ rc = asn1_strncpy(text, &text1, sizeof(text));
+ printf("Decoding string from asn.1: %s\n", text);
+
+ ASSERT(rc == 16);
+ ASSERT(!strcmp(text, (char *)text1.buf));
+
}
int main(int argc, char **argv)