More tests

This commit is contained in:
Frank Denis 2017-09-19 22:08:31 +02:00
parent aec433cecc
commit 41dc933226
2 changed files with 50 additions and 1 deletions

View File

@ -6,12 +6,48 @@
# include <signal.h>
static void
sigabrt_handler_6(int sig)
sigabrt_handler_10(int sig)
{
(void) sig;
exit(0);
}
static void
sigabrt_handler_9(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_10);
assert(sodium_base642bin(NULL, 1, NULL, 1, NULL, NULL, NULL, -1) == -1);
exit(1);
}
static void
sigabrt_handler_8(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_9);
assert(sodium_bin2base64(NULL, 1, NULL, 1, sodium_base64_VARIANT_ORIGINAL) == NULL);
exit(1);
}
static void
sigabrt_handler_7(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_8);
assert(sodium_bin2base64(NULL, 1, NULL, 1, -1) == NULL);
exit(1);
}
static void
sigabrt_handler_6(int sig)
{
(void) sig;
signal(SIGABRT, sigabrt_handler_7);
assert(sodium_pad(NULL, NULL, SIZE_MAX, 16, 1) == -1);
exit(1);
}
static void
sigabrt_handler_5(int sig)
{

View File

@ -209,6 +209,19 @@ main(void)
assert(sodium_base642bin(buf1, sizeof buf1, "O", (size_t) 1U, NULL, NULL, NULL,
sodium_base64_VARIANT_ORIGINAL_NO_PADDING) == -1);
assert(sodium_base642bin(buf1, sizeof buf1, "kaw", (size_t) 3U, NULL, NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == -1);
assert(sodium_base642bin(buf1, sizeof buf1, "kQ*", (size_t) 3U, "@", NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == -1);
assert(sodium_base642bin(buf1, sizeof buf1, "kQ*", (size_t) 3U, "*", NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == -1);
assert(sodium_base642bin(buf1, sizeof buf1, "kaw=**", (size_t) 6U, "*", NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == 0);
assert(sodium_base642bin(buf1, sizeof buf1, "kaw*=*", (size_t) 6U, "~*", NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == 0);
assert(sodium_base642bin(buf1, sizeof buf1, "ka*w*=*", (size_t) 7U, "*~", NULL, NULL,
sodium_base64_VARIANT_ORIGINAL) == 0);
for (i = 0; i < 1000; i++) {
assert(sizeof buf1 >= 100);
bin_len = (size_t) randombytes_uniform(100);