tests: Test asn1_strncpy function
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 @@
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 @@
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)