]> git.lizzy.rs Git - nothing.git/blobdiff - test/test.h
(#1102) Introduce overloaded print and equal for testing
[nothing.git] / test / test.h
index 44f8089d6dd1435f7c6c9277973cedffea1f0c54..4c04963254721e0e3dd93839c62f5c22e7314985 100644 (file)
@@ -2,6 +2,7 @@
 #define TEST_H_
 
 #include "math.h"
+#include "overloading.h"
 
 #define TEST_RUN(name)                          \
     if (name() < 0) {                           \
         }                                                               \
     }
 
+#define EPIC_ASSERT_EQ(type, expected, actual)                          \
+    {                                                                   \
+        type _expected = (expected);                                    \
+        type _actual = (actual);                                        \
+        if (!EQUAL(_expected, _actual)) {                               \
+            fprintf(stderr, "\n%s:%d: ASSERT_EQ: \n",                   \
+                    __FILE__, __LINE__);                                \
+            fputs("Expected: ", stderr);                                \
+            print(_expected, stderr);                                   \
+            fputc('\n', stderr);                                        \
+            fputs("Actual:   ", stderr);                                \
+            print(_actual, stderr);                                     \
+            fputc('\n', stderr);                                        \
+            return -1;                                                  \
+        }                                                               \
+    }
+
 #define ASSERT_TRUE(condition, handler)                                 \
     if (!(condition)) {                                                 \
         fprintf(stderr, "\n%s:%d: ASSERT_TRUE: false\n",                \