summaryrefslogtreecommitdiffstats
path: root/test/test_test.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2017-05-15 08:49:36 +1000
committerAndy Polyakov <appro@openssl.org>2017-05-19 13:24:50 +0200
commitffbaf06ade6dab6a0805a24087cf2e84c5db8d43 (patch)
tree00972a084e8c93c54b700795ec67131c5d19695b /test/test_test.c
parent5ec3210fc106ecc6badb48db6cfb1493a7607763 (diff)
Reformat the output of BIGNUMS where test cases fail.
Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3465)
Diffstat (limited to 'test/test_test.c')
-rw-r--r--test/test_test.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_test.c b/test/test_test.c
index 0094c1c643..7a5079a140 100644
--- a/test/test_test.c
+++ b/test/test_test.c
@@ -306,6 +306,9 @@ static int test_bignum(void)
| !TEST(0, TEST_BN_gt_zero(a))
| !TEST(1, TEST_BN_even(a))
| !TEST(0, TEST_BN_odd(a))
+ | !TEST(1, TEST_BN_eq(b, c))
+ | !TEST(0, TEST_BN_eq(a, b))
+ | !TEST(1, TEST_BN_ne(NULL, c))
| !TEST(1, TEST_int_eq(BN_dec2bn(&b, "1"), 1))
| !TEST(1, TEST_BN_eq_word(b, 1))
| !TEST(1, TEST_BN_eq_one(b))
@@ -374,6 +377,46 @@ static int test_long_output(void)
& TEST(0, TEST_mem_eq(r, strlen(r), s, strlen(s)));
}
+static int test_long_bignum(void)
+{
+ int r;
+ BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
+ const char as[] = "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789012"
+ "FFFFFF";
+ const char bs[] = "1234567890123456789012345678901234567890123456789012"
+ "1234567890123456789012345678901234567890123456789013"
+ "987657";
+ const char cs[] = "-" /* 64 characters plus sign */
+ "123456789012345678901234567890"
+ "123456789012345678901234567890"
+ "ABCD";
+ const char ds[] = "-" /* 63 characters plus sign */
+ "23456789A123456789B123456789C"
+ "123456789D123456789E123456789F"
+ "ABCD";
+
+ r = TEST_true(BN_hex2bn(&a, as))
+ && TEST_true(BN_hex2bn(&b, bs))
+ && TEST_true(BN_hex2bn(&c, cs))
+ && TEST_true(BN_hex2bn(&d, ds))
+ && (TEST(0, TEST_BN_eq(a, b))
+ & TEST(0, TEST_BN_eq(b, a))
+ & TEST(0, TEST_BN_eq(b, NULL))
+ & TEST(0, TEST_BN_eq(NULL, a))
+ & TEST(1, TEST_BN_ne(a, NULL))
+ & TEST(0, TEST_BN_eq(c, d)));
+ BN_free(a);
+ BN_free(b);
+ BN_free(c);
+ BN_free(d);
+ return r;
+}
+
static int test_messages(void)
{
TEST_info("This is an %s message.", "info");
@@ -452,6 +495,7 @@ void register_tests(void)
ADD_TEST(test_memory_overflow);
ADD_TEST(test_bignum);
ADD_TEST(test_long_output);
+ ADD_TEST(test_long_bignum);
ADD_TEST(test_messages);
ADD_TEST(test_single_eval);
}