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 043f5df commit a4f1833
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/short-outbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,41 @@ 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);
}

return ok ? 0 : 1;
Expand Down

0 comments on commit a4f1833

Please sign in to comment.