Fix minor type warnings and risk of memory leak in testutil/driver.c
[openssl.git] / test / test_test.c
index a1b04561b3a164e187e971d93cf519d513534ba1..ae16d8285c2cdb7ce56a7ec0f1d7f160ce7d47b2 100644 (file)
@@ -477,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);
@@ -496,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;
 }