summaryrefslogtreecommitdiff
path: root/lily-test.h
diff options
context:
space:
mode:
Diffstat (limited to 'lily-test.h')
-rw-r--r--lily-test.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/lily-test.h b/lily-test.h
index 6aafb8f..e4f1676 100644
--- a/lily-test.h
+++ b/lily-test.h
@@ -187,6 +187,18 @@ void lily_require(int x, const char *location, const char *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)
+#define LILY_REQUIRE_EQF(x, y, xstr, ystr, fmt) \
+ lily_require(fabs(x-y) < lily_g.epsilon, LILY_LOCATION, \
+ "REQUIRE failed: %s == %s\n %s = " fmt "\n %s = " fmt "\n epsilon: %f", \
+ xstr, ystr, xstr, x, ystr, y, lily_g.epsilon)
+#define REQUIRE_EQF(x, y, fmt) LILY_REQUIRE_EQF(x, y, #x, #y, fmt)
+
+#define LILY_REQUIRE_EQS(x, y, xstr, ystr) \
+ lily_require(strcmp(x, y) == 0, LILY_LOCATION, \
+ "REQUIRE failed: %s == %s\n %s = \"%s\"\n %s = \"%s\"", \
+ xstr, ystr, xstr, x, ystr, y)
+#define REQUIRE_EQS(x, y) LILY_REQUIRE_EQS(x, y, #x, #y)
+
void lily_begin();
void lily_finish();
@@ -331,6 +343,12 @@ void lily_require(int x, const char *location, const char *fmt, ...)
void lily_begin()
{
+ lily_g.n_tests = 0;
+ lily_g.n_tests_failed = 0;
+ lily_g.n_assertions_failed = 0;
+ lily_g.n_assertions_failed = 0;
+ lily_g.epsilon = 1e-3;
+
printf("================================================================================\n");
printf("lily-test version %d.%d.%d\n", LILY_VERSION_MAJOR, LILY_VERSION_MINOR, LILY_VERSION_PATCH);
}