summaryrefslogtreecommitdiff
path: root/testsuite/backend/genesys/minigtest.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:13:01 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:13:01 +0100
commitffa8801644a7d53cc1c785e3450f794c07a14eb0 (patch)
tree8d72a18a9a08b9151d12badcb1c78ce06a059f62 /testsuite/backend/genesys/minigtest.h
parent1687222e1b9e74c89cafbb5910e72d8ec7bfd40f (diff)
New upstream version 1.0.29upstream/1.0.29
Diffstat (limited to 'testsuite/backend/genesys/minigtest.h')
-rw-r--r--testsuite/backend/genesys/minigtest.h38
1 files changed, 36 insertions, 2 deletions
diff --git a/testsuite/backend/genesys/minigtest.h b/testsuite/backend/genesys/minigtest.h
index 752efe1..9a38e77 100644
--- a/testsuite/backend/genesys/minigtest.h
+++ b/testsuite/backend/genesys/minigtest.h
@@ -38,7 +38,7 @@ inline void print_location(std::ostream& out, const char* function, const char*
template<class T, class U>
void check_equal(const T& t, const U& u, const char* function, const char* path, unsigned line)
{
- if (t != u) {
+ if (!(t == u)) {
s_num_failures++;
std::cerr << "FAILURE at ";
print_location(std::cerr, function, path, line);
@@ -64,14 +64,48 @@ inline void check_true(bool x, const char* function, const char* path, unsigned
std::cerr << "\n";
}
+inline void check_raises_success(const char* function, const char* path, unsigned line)
+{
+ s_num_successes++;
+ std::cerr << "SUCCESS at ";
+ print_location(std::cerr, function, path, line);
+ std::cerr << "\n";
+}
+
+inline void check_raises_did_not_raise(const char* function, const char* path, unsigned line)
+{
+ s_num_failures++;
+ std::cerr << "FAILURE at ";
+ print_location(std::cerr, function, path, line);
+ std::cerr << " : did not raise exception\n";
+
+}
+
+inline void check_raises_raised_unexpected(const char* function, const char* path, unsigned line)
+{
+ s_num_failures++;
+ std::cerr << "FAILURE at ";
+ print_location(std::cerr, function, path, line);
+ std::cerr << " : unexpected exception raised\n";
+}
#define ASSERT_EQ(x, y) do { check_equal((x), (y), __func__, __FILE__, __LINE__); } \
while (false)
#define ASSERT_TRUE(x) do { check_true(bool(x), __func__, __FILE__, __LINE__); } \
while (false)
-#define ASSERT_FALSE(x) do { !check_true(bool(x), __func__, __FILE__, __LINE__); } \
+#define ASSERT_FALSE(x) do { check_true(!bool(x), __func__, __FILE__, __LINE__); } \
while (false)
+#define ASSERT_RAISES(x, T) \
+ do { try { \
+ x; \
+ check_raises_did_not_raise(__func__, __FILE__, __LINE__); \
+ } catch (const T&) { \
+ check_raises_success(__func__, __FILE__, __LINE__); \
+ } catch (...) { \
+ check_raises_raised_unexpected(__func__, __FILE__, __LINE__); \
+ } } while (false)
+
int finish_tests();
#endif