tests: Test asn1_strncpy function

This commit is contained in:
Daniel Willmann 2015-11-23 15:48:59 +01:00
parent 6e59d413a2
commit ec0e50e148
1 changed files with 15 additions and 0 deletions

View File

@ -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)