summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2021-12-27 17:20:55 -0600
committersanine <sanine.not@pm.me>2021-12-27 17:20:55 -0600
commit0e16dbc5c78a2715fbbda5cae8a3b422d721b871 (patch)
tree54050cda2f0c37d2a9fde73fb1abcb7eccf9be9d /tests
parentff77a89b252ad79cd005afe361c4b5860c3e7c3a (diff)
add basic assertions
Diffstat (limited to 'tests')
-rw-r--r--tests/assertions.c29
-rw-r--r--tests/main.c1
-rw-r--r--tests/tests.h1
3 files changed, 31 insertions, 0 deletions
diff --git a/tests/assertions.c b/tests/assertions.c
index baa0045..0a2875d 100644
--- a/tests/assertions.c
+++ b/tests/assertions.c
@@ -44,3 +44,32 @@ const char *test_assert_msg()
return 0;
}
+
+
+const char *test_assert_true()
+{
+ int val = setjmp(_lily_globals.env);
+ if (val != 0)
+ return "true assertion failed incorrectly!";
+
+ lily_assert_true(true);
+
+ int passed_thru = 0;
+ _lily_globals.error_msg = NULL;
+ _lily_globals.error_location = "";
+ val = setjmp(_lily_globals.env);
+
+ if (passed_thru == 0) {
+ passed_thru = 1;
+ lily_assert_true(false);
+ return "false assertion incorrectly succeeded!";
+ }
+ else {
+ if (strcmp(_lily_globals.error_msg, "false is not true") != 0)
+ return "false assertion produced incorrect error message!";
+ if (strcmp(_lily_globals.error_location, "tests/assertions.c:64") != 0)
+ return "false assertion produced incorrect error location!";
+ }
+
+ return 0;
+}
diff --git a/tests/main.c b/tests/main.c
index 0ac74ac..65683ee 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -12,6 +12,7 @@ int main()
run_test(test_LILY_LOCATION);
run_test(test_assert_msg);
+ run_test(test_assert_true);
return 0;
}
diff --git a/tests/tests.h b/tests/tests.h
index 7889445..7962104 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -9,5 +9,6 @@ int validate_message(const char* received, const char* expected,
// test cases
const char* test_LILY_LOCATION();
const char* test_assert_msg();
+const char* test_assert_true();
#endif