aboutsummaryrefslogtreecommitdiff
path: root/tests/assert.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assert.hpp')
-rw-r--r--tests/assert.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/assert.hpp b/tests/assert.hpp
index 86f74f2..03157c6 100644
--- a/tests/assert.hpp
+++ b/tests/assert.hpp
@@ -2,19 +2,23 @@
#include <cstdlib>
#include <iostream>
+#include <sstream>
+#include <stdexcept>
template <typename T>
static void assertEquals(const T &expected, const T &actual)
{
if(expected != actual)
{
- std::cerr << "Assertion failed!\nExpected: " << expected << ", actual: " << actual << std::endl;
- exit(1);
+ std::stringstream ss;
+ ss << "Assertion failed!\nExpected: " << expected << ", actual: " << actual << std::endl;
+ throw std::runtime_error(ss.str());
}
}
static void fail(const std::string &errMsg)
{
- fprintf(stderr, "Fail:\n%.*s\n", errMsg.size(), errMsg.c_str());
- exit(1);
+ std::stringstream ss;
+ ss << "Fail:\n" << errMsg << std::endl;
+ throw std::runtime_error(ss.str());
}