Skip to content

Commit

Permalink
test/short-outbuf: Add two more cases for crypt_ra.
Browse files Browse the repository at this point in the history
 * outbuf != NULL with negative size parameter, and
 * outbuf == NULL with valid size parameter.
  • Loading branch information
besser82 committed Jan 16, 2025
1 parent 401b114 commit ac873d4
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/short-outbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,42 @@ main (void)
printf ("Test %zu.1: %s, expected: \"%-2s\", got: \"%-2s\"\n",
s, result, testcases[i].exp_ra, outbuf);

j = -1;

crypt_ra ("@@", "@@", (void **) &outbuf, &j);

if (!strncmp (testcases[i].exp_ra, outbuf, strlen(outbuf)))
{
strcpy (result, "PASS");
}
else
{
strcpy (result, "FAIL");
ok = false;
}

printf ("Test %zu.2: %s, expected: \"%-2s\", got: \"%-2s\"\n",
s, result, testcases[i].exp_ra, outbuf);

free (outbuf);
outbuf = NULL;
j = sizeof (struct crypt_data);

crypt_ra ("@@", "@@", (void **) &outbuf, &j);

if (!strncmp (testcases[i].exp_ra, outbuf, strlen(outbuf)))
{
strcpy (result, "PASS");
}
else
{
strcpy (result, "FAIL");
ok = false;
}

printf ("Test %zu.3: %s, expected: \"%-2s\", got: \"%-2s\"\n",
s, result, testcases[i].exp_ra, outbuf);

free (outbuf);
}

Expand Down

0 comments on commit ac873d4

Please sign in to comment.