summaryrefslogtreecommitdiff
path: root/lily-test.h
diff options
context:
space:
mode:
Diffstat (limited to 'lily-test.h')
-rw-r--r--lily-test.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/lily-test.h b/lily-test.h
index f0d14e7..ac956aa 100644
--- a/lily-test.h
+++ b/lily-test.h
@@ -138,10 +138,17 @@ void lily_check(int x, const char *location, const char *fmt, ...);
#define LILY_CHECK(x) LILY_CHECK_(STR(x), x, LILY_LOCATION)
#define CHECK(x) LILY_CHECK(x)
-#define LILY_CHECK_EQ_(test, location, fmt, x, y, xstr, ystr) \
- lily_check(test, location, "CHECK failed: %s == %s (" fmt " == " fmt ")", xstr, ystr, x, y)
-#define LILY_CHECK_EQ(x, y, xstr, ystr, fmt) LILY_CHECK_EQ_(x == y, LILY_LOCATION, fmt, x, y, xstr, ystr)
-#define CHECK_EQ(x, y, fmt) LILY_CHECK_EQ(x, y, #x, #y, fmt)
+#define LILY_CHECK_CMP_(x, y, xstr, ystr, cmp, cmpstr, fmt) \
+ lily_check(x cmp y, LILY_LOCATION, "CHECK failed: %s " cmpstr " %s (" fmt " " cmpstr " " fmt ")", xstr, ystr, x, y)
+#define LILY_CHECK_CMP(x, cmp, y, fmt) LILY_CHECK_CMP_(x, y, #x, #y, cmp, #cmp, fmt)
+
+/* check comparision assertions */
+#define CHECK_EQ(x, y, fmt) LILY_CHECK_CMP(x, ==, y, fmt)
+#define CHECK_NEQ(x, y, fmt) LILY_CHECK_CMP(x, !=, y, fmt)
+#define CHECK_LT(x, y, fmt) LILY_CHECK_CMP(x, <, y, fmt)
+#define CHECK_LE(x, y, fmt) LILY_CHECK_CMP(x, <=, y, fmt)
+#define CHECK_GT(x, y, fmt) LILY_CHECK_CMP(x, >, y, fmt)
+#define CHECK_GE(x, y, fmt) LILY_CHECK_CMP(x, >=, y, fmt)
void lily_require(int x, const char *location, const char *fmt, ...);
@@ -150,6 +157,18 @@ void lily_require(int x, const char *location, const char *fmt, ...);
#define LILY_REQUIRE(x) LILY_REQUIRE_(STR(x), x, LILY_LOCATION)
#define REQUIRE(x) LILY_REQUIRE(x)
+#define LILY_REQUIRE_CMP_(x, y, xstr, ystr, cmp, cmpstr, fmt) \
+ lily_require(x cmp y, LILY_LOCATION, "REQUIRE failed: %s " cmpstr " %s (" fmt " " cmpstr " " fmt ")", xstr, ystr, x, y)
+#define LILY_REQUIRE_CMP(x, cmp, y, fmt) LILY_REQUIRE_CMP_(x, y, #x, #y, cmp, #cmp, fmt)
+
+/* require comparison assertions */
+#define REQUIRE_EQ(x, y, fmt) LILY_REQUIRE_CMP(x, ==, y, fmt)
+#define REQUIRE_NEQ(x, y, fmt) LILY_REQUIRE_CMP(x, !=, y, fmt)
+#define REQUIRE_LT(x, y, fmt) LILY_REQUIRE_CMP(x, <, y, fmt)
+#define REQUIRE_LE(x, y, fmt) LILY_REQUIRE_CMP(x, <=, y, fmt)
+#define REQUIRE_GT(x, y, fmt) LILY_REQUIRE_CMP(x, >, y, fmt)
+#define REQUIRE_GE(x, y, fmt) LILY_REQUIRE_CMP(x, >=, y, fmt)
+
void lily_run_test(void (*test)());