]> git.lizzy.rs Git - nothing.git/blobdiff - test/test.h
(#815) Integrate Point Layer with Level and LevelEditor
[nothing.git] / test / test.h
index 0cafc34b6f96391239f41b40a614c382ee6222ae..f39cc7a5758a8bf1e2a12ca5d9b602d1d71f9fa3 100644 (file)
@@ -8,6 +8,9 @@
         return -1;                              \
     }
 
+#define TEST_IGNORE(name)                       \
+    (void)(name)                                \
+
 #define TEST(name)                              \
     static int name##_body(void);               \
     static int name(void) {                     \
         return -1;                                                      \
     }
 
+#define ASSERT_LONGINTEQ(expected, actual)                              \
+    if (expected != actual) {                                           \
+        fprintf(stderr, "\n%s:%d: ASSERT_LONGINTEQ: \n",                \
+                __FILE__, __LINE__);                                    \
+        fprintf(stderr, "  Expected: %ld\n", expected);                 \
+        fprintf(stderr, "  Actual: %ld\n", actual);                     \
+        return -1;                                                      \
+    }
+
+
 #define ASSERT_FLOATEQ(expected, actual, margin)                        \
     if (fabsf(expected - actual) > margin) {                            \
-        fprintf(stderr, "\n%s:%d: ASSERT_INTEQ: \n",                    \
+        fprintf(stderr, "\n%s:%d: ASSERT_FLOATEQ: \n",                  \
                 __FILE__, __LINE__);                                    \
         fprintf(stderr, "  Expected: %f\n", expected);                  \
         fprintf(stderr, "  Actual: %f\n", actual);                      \
         return -1;                                                      \
     }
 
-#define ASSERT_TRUE(condition, message)                                 \
-    if (!condition) {                                                   \
+#define ASSERT_EQ(type, expected, actual, handler)                      \
+    {                                                                   \
+        type _expected = (expected);                                    \
+        type _actual = (actual);                                        \
+        if (_expected != _actual) {                                     \
+            fprintf(stderr, "\n%s:%d: ASSERT_EQ: \n",                   \
+                    __FILE__, __LINE__);                                \
+            handler                                                     \
+            return -1;                                                  \
+        }                                                               \
+    }
+
+#define ASSERT_TRUE(condition, handler)                                 \
+    if (!(condition)) {                                                 \
         fprintf(stderr, "\n%s:%d: ASSERT_TRUE: false\n",                \
                 __FILE__, __LINE__);                                    \
-        fprintf(stderr, "%s\n", message);                               \
+        handler                                                         \
+        return -1;                                                      \
+    }
+
+#define ASSERT_FALSE(condition, handler)                                \
+    if (condition) {                                                    \
+        fprintf(stderr, "\n%s:%d: ASSERT_FALSE: false\n",               \
+                __FILE__, __LINE__);                                    \
+        handler                                                         \
         return -1;                                                      \
     }