aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/tests.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/tests.h')
-rw-r--r--src/tests/tests.h39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/tests/tests.h b/src/tests/tests.h
index c7bed64d9..b52ecce0d 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -184,8 +184,40 @@ class Test
bool test_lt(const std::string& what, size_t produced, size_t expected);
bool test_gte(const std::string& what, size_t produced, size_t expected);
- bool test_rc_ok(const std::string& func, int rc);
- bool test_rc_fail(const std::string& func, const std::string& why, int rc);
+ template<typename T>
+ bool test_rc_ok(const std::string& func, T rc)
+ {
+ static_assert(std::is_integral<T>::value, "Integer required.");
+
+ if(rc != 0)
+ {
+ std::ostringstream err;
+ err << m_who;
+ err << " " << func;
+ err << " unexpectedly failed with error code " << rc;
+ return test_failure(err.str());
+ }
+
+ return test_success();
+ }
+
+ template<typename T>
+ bool test_rc_fail(const std::string& func, const std::string& why, T rc)
+ {
+ static_assert(std::is_integral<T>::value, "Integer required.");
+
+ if(rc == 0)
+ {
+ std::ostringstream err;
+ err << m_who;
+ err << " call to " << func << " unexpectedly succeeded";
+ err << " expecting failure because " << why;
+ return test_failure(err.str());
+ }
+
+ return test_success();
+ }
+
bool test_rc(const std::string& func, int expected, int rc);
#if defined(BOTAN_HAS_BIGINT)
@@ -311,10 +343,12 @@ class Test
static void setup_tests(size_t soak,
bool log_succcss,
const std::string& data_dir,
+ const std::string& pkcs11_lib,
Botan::RandomNumberGenerator* rng);
static size_t soak_level();
static bool log_success();
+ static std::string pkcs11_lib();
static const std::string& data_dir();
@@ -327,6 +361,7 @@ class Test
static Botan::RandomNumberGenerator* m_test_rng;
static size_t m_soak_level;
static bool m_log_success;
+ static std::string m_pkcs11_lib;
};
/*