X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=test%2Fsanitytest.c;h=da74e7eca1ac668303cb0fd1163ae2646db488cb;hp=80a19e992d5b8f4f22ded260a6a6358a915d3538;hb=eefc485bda4ab1ac7293b4c749c251b662d9fba8;hpb=ad887416f1e59c3294a7d8f83a0ca77120523b4a diff --git a/test/sanitytest.c b/test/sanitytest.c index 80a19e992d..da74e7eca1 100644 --- a/test/sanitytest.c +++ b/test/sanitytest.c @@ -8,9 +8,8 @@ */ #include -#include - #include "testutil.h" +#include "internal/numbers.h" static int test_sanity_null_zero(void) { @@ -19,7 +18,7 @@ static int test_sanity_null_zero(void) /* Is NULL equivalent to all-bytes-zero? */ p = NULL; - memset(bytes, 0, sizeof bytes); + memset(bytes, 0, sizeof(bytes)); return TEST_mem_eq(&p, sizeof(p), bytes, sizeof(bytes)); } @@ -66,7 +65,7 @@ static int test_sanity_sign(void) return 1; } -static int test_sanity_unsigned_convertion(void) +static int test_sanity_unsigned_conversion(void) { /* Check that unsigned-to-signed conversions preserve bit patterns */ if (!TEST_int_eq((int)((unsigned int)INT_MAX + 1), INT_MIN) @@ -75,13 +74,24 @@ static int test_sanity_unsigned_convertion(void) return 1; } +static int test_sanity_range(void) +{ + /* This isn't possible to check using the framework functions */ + if (SIZE_MAX < INT_MAX) { + TEST_error("int must not be wider than size_t"); + return 0; + } + return 1; +} + int setup_tests(void) { ADD_TEST(test_sanity_null_zero); ADD_TEST(test_sanity_enum_size); ADD_TEST(test_sanity_twos_complement); ADD_TEST(test_sanity_sign); - ADD_TEST(test_sanity_unsigned_convertion); + ADD_TEST(test_sanity_unsigned_conversion); + ADD_TEST(test_sanity_range); return 1; }