summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/dgunit.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/dgunit.h b/test/dgunit.h
index a010092..358c70d 100644
--- a/test/dgunit.h
+++ b/test/dgunit.h
@@ -34,6 +34,7 @@
#include <string>
#include <sstream>
#include <fstream>
+#include <cmath>
class DGUnit
{
@@ -173,6 +174,18 @@ protected:
#define DGUNIT_ASSERT(value) \
dg_assert(value, #value, __FILE__, __LINE__)
+ void assert_equal(double expected, double value,
+ const char* file, std::size_t line)
+ {
+ if(std::fabs(expected - value) > 0.0000001)
+ {
+ std::stringstream ss;
+ ss << "equality assertion failed\n"
+ "- Expected: " << expected << "\n"
+ "- Actual : " << value << "\n";
+ throw test_result{"", file, line, ss.str()};
+ }
+ }
template<typename T>
void assert_equal(T expected, T value,
const char* file, std::size_t line)