From e716cd97645ab4212dd4460e144ab480166844d4 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 23 Mar 2019 13:46:31 +0100 Subject: [PATCH] Improved ASSERT macro, and renamed tests/check.hpp to tests/assert.hpp --- tests/assert.hpp | 8 ++++++++ tests/check.hpp | 8 -------- tests/crypto_test.cpp | 5 ++--- tests/io_test.cpp | 2 +- tests/parse_test.cpp | 2 +- tests/status_code_test.cpp | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) create mode 100644 tests/assert.hpp delete mode 100644 tests/check.hpp diff --git a/tests/assert.hpp b/tests/assert.hpp new file mode 100644 index 0000000..e6ede15 --- /dev/null +++ b/tests/assert.hpp @@ -0,0 +1,8 @@ +#ifndef TESTS_ASSERT_HPP +#define TESTS_ASSERT_HPP + +#include + +#define ASSERT(e) ((void)((e) ? ((void)0) : ((void)fprintf(stderr, "Assertion failed: (%s), function %s, file %s, line %u.\n", #e, __func__, __FILE__, __LINE__), abort()))) + +#endif /* TESTS_ASSERT_HPP */ diff --git a/tests/check.hpp b/tests/check.hpp deleted file mode 100644 index bfead5f..0000000 --- a/tests/check.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CHECK_HPP -#define CHECK_HPP - -#include - -#define ASSERT(cond) if (!(cond)) { std::abort(); } - -#endif /* CHECK_HPP */ diff --git a/tests/crypto_test.cpp b/tests/crypto_test.cpp index ed66001..1456cc7 100644 --- a/tests/crypto_test.cpp +++ b/tests/crypto_test.cpp @@ -1,7 +1,6 @@ -#include - -#include "check.hpp" +#include "assert.hpp" #include "crypto.hpp" +#include using namespace std; using namespace SimpleWeb; diff --git a/tests/io_test.cpp b/tests/io_test.cpp index 6c1b949..d15270b 100644 --- a/tests/io_test.cpp +++ b/tests/io_test.cpp @@ -1,6 +1,6 @@ +#include "assert.hpp" #include "client_http.hpp" #include "server_http.hpp" -#include "check.hpp" using namespace std; diff --git a/tests/parse_test.cpp b/tests/parse_test.cpp index 05a6138..c521b38 100644 --- a/tests/parse_test.cpp +++ b/tests/parse_test.cpp @@ -1,6 +1,6 @@ +#include "assert.hpp" #include "client_http.hpp" #include "server_http.hpp" -#include "check.hpp" #include using namespace std; diff --git a/tests/status_code_test.cpp b/tests/status_code_test.cpp index f9b623d..679e504 100644 --- a/tests/status_code_test.cpp +++ b/tests/status_code_test.cpp @@ -1,5 +1,5 @@ +#include "assert.hpp" #include "status_code.hpp" -#include "check.hpp" using namespace SimpleWeb;