Remove a pointless "#if 0" block from BN_mul.
[openssl.git] / test / test_test.c
index 7a5079a1402816af77214586d8de48e2e00e5585..051058fffe1cab27561b0e560005dbd91c222a1b 100644 (file)
@@ -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 <stdio.h>
 #include <string.h>
 
@@ -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;
 
@@ -308,7 +306,7 @@ static int test_bignum(void)
         | !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(0, 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))
@@ -479,6 +477,38 @@ static int test_single_eval(void)
            && TEST_mem_eq(p--, sizeof("456"), "456", sizeof("456"));
 }
 
+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;
+}
+
+
 void register_tests(void)
 {
     ADD_TEST(test_int);
@@ -494,8 +524,10 @@ void register_tests(void)
     ADD_TEST(test_memory);
     ADD_TEST(test_memory_overflow);
     ADD_TEST(test_bignum);
-    ADD_TEST(test_long_output);
     ADD_TEST(test_long_bignum);
+    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));
 }