From aa206b75f8c89ab5e0fdeede558775ae7c072113 Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 21 Dec 2021 01:09:07 -0600 Subject: implement lily_assert_equal() --- src/test.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/test.c') diff --git a/src/test.c b/src/test.c index 146f636..8a5d141 100644 --- a/src/test.c +++ b/src/test.c @@ -77,9 +77,31 @@ lily_test check_assert() } +const char *assert_eq_true() +{ + lily_assert_equal(15, 15); + return 0; +} +const char *assert_eq_false() +{ + lily_assert_equal(14, 15); + return 0; +} + lily_test check_other_asserts() { - + if (assert_eq_true() != 0) + return "equality assertion returned non-zero when true!"; + const char *result = assert_eq_false(); + if (result == 0) + return "equality assertion returned zero when false!"; + char *message; + if (!get_message(&message, result)) + return "false equality assertion returned malformed message!"; + if (strcmp(message, "'14' is not equal to '15'") != 0) + return "false equality assertion returned incorrect message!"; + + return 0; } @@ -87,6 +109,7 @@ int main() { run_test("check LILY_INIT()", check_init); run_test("check basic assertion", check_assert); + run_test("check other asserts", check_other_asserts); printf("all tests finished.\n"); return 0; -- cgit v1.2.1