From ac873d489c9f54b50945d5222f8e7791ec0bc20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Thu, 16 Jan 2025 13:44:20 +0100 Subject: [PATCH] test/short-outbuf: Add two more cases for crypt_ra. * outbuf != NULL with negative size parameter, and * outbuf == NULL with valid size parameter. --- test/short-outbuf.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/short-outbuf.c b/test/short-outbuf.c index 3f708a2e..d5e9cec2 100644 --- a/test/short-outbuf.c +++ b/test/short-outbuf.c @@ -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); }