tests: Test cropping of string still is NULL-terminated

This commit is contained in:
Daniel Willmann 2015-11-23 15:50:06 +01:00
parent 53018e937c
commit 8ea918d772
1 changed files with 9 additions and 0 deletions

View File

@ -62,6 +62,11 @@ const OCTET_STRING_t text1 = {
.size = 16,
};
const OCTET_STRING_t text2 = {
.buf = "01234567890123456789012345678901234567890",
.size = 40,
};
void test_asn1_helpers(void)
{
int rc;
@ -91,6 +96,10 @@ void test_asn1_helpers(void)
ASSERT(rc == 16);
ASSERT(!strcmp(text, (char *)text1.buf));
rc = asn1_strncpy(text, &text2, sizeof(text));
printf("Decoding large string from asn1: %s\n", text);
ASSERT(rc == 31);
}
int main(int argc, char **argv)