X-Git-Url: https://git.openssl.org/gitweb/?a=blobdiff_plain;f=test%2Ftest_test.c;h=2ec2b51159ef34148b5347c5c0987e25c646476b;hb=44f19af7434cdb996f1ce11789150baa07db27e6;hp=116dc731f67777ef169d5cc05d3442a032783590;hpb=e2c1aa1ba3bc48eaaaed02c6a9a227d765e42fcb;p=openssl.git diff --git a/test/test_test.c b/test/test_test.c index 116dc731f6..2ec2b51159 100644 --- a/test/test_test.c +++ b/test/test_test.c @@ -1,5 +1,6 @@ /* * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -7,10 +8,6 @@ * https://www.openssl.org/source/license.html */ -/* - * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. - */ - #include #include @@ -19,7 +16,7 @@ #include #include -#include "e_os.h" +#include "internal/nelem.h" #include "testutil.h" #define TEST(expected, test) test_case((expected), #test, (test)) @@ -249,7 +246,8 @@ static int test_string(void) | !TEST(0, TEST_str_eq("\1\2\3\4\5", "\1x\3\6\5")) | !TEST(0, TEST_str_ne("abc", buf)) | !TEST(1, TEST_str_ne("abc", NULL)) - | !TEST(1, TEST_str_ne(NULL, buf))) + | !TEST(1, TEST_str_ne(NULL, buf)) + | !TEST(0, TEST_str_eq("abcdef", "abcdefghijk"))) goto err; return 1; @@ -479,7 +477,39 @@ static int test_single_eval(void) && TEST_mem_eq(p--, sizeof("456"), "456", sizeof("456")); } -void register_tests(void) +static int test_output(void) +{ + const char s[] = "1234567890123456789012345678901234567890123456789012" + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + test_output_string("test", s, sizeof(s) - 1); + test_output_memory("test", (const unsigned char *)s, sizeof(s)); + return 1; +} + +static const char *bn_output_tests[] = { + NULL, + "0", + "-12345678", + "1234567890123456789012345678901234567890123456789012" + "1234567890123456789012345678901234567890123456789013" + "987657" +}; + +static int test_bn_output(int n) +{ + BIGNUM *b = NULL; + + if (bn_output_tests[n] != NULL + && !TEST_true(BN_hex2bn(&b, bn_output_tests[n]))) + return 0; + test_output_bignum(bn_output_tests[n], b); + BN_free(b); + return 1; +} + + +int setup_tests(void) { ADD_TEST(test_int); ADD_TEST(test_uint); @@ -498,4 +528,7 @@ void register_tests(void) ADD_TEST(test_long_output); ADD_TEST(test_messages); ADD_TEST(test_single_eval); + ADD_TEST(test_output); + ADD_ALL_TESTS(test_bn_output, OSSL_NELEM(bn_output_tests)); + return 1; }