From 0e16dbc5c78a2715fbbda5cae8a3b422d721b871 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 27 Dec 2021 17:20:55 -0600 Subject: add basic assertions --- tests/assertions.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/assertions.c') 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; +} -- cgit v1.2.1