From 182b4002e63f330de6150e160a1ad23b1e6b33b8 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 19 Dec 2022 20:29:39 -0600 Subject: add INFO macro --- tests/assertions.c | 34 ++++++++++++++++++++++++++++++++++ tests/tests.h | 1 + 2 files changed, 35 insertions(+) (limited to 'tests') diff --git a/tests/assertions.c b/tests/assertions.c index 6ad855a..156a484 100644 --- a/tests/assertions.c +++ b/tests/assertions.c @@ -2,6 +2,40 @@ #include "tests.h" +const char * test_INFO() +{ + lily_g.HEAD.next = NULL; + lily_g.TAIL = &(lily_g.HEAD); + lily_g.failed = 0; + + INFO("the number is %d", 10); + INFO("the string is '%s'", "hello world"); + + if (lily_g.failed) + return "INFO caused failure!"; + + if (lily_g.HEAD.next == NULL) + return "INFO did not append any messages!"; + + lily_test_msg_t *m = lily_g.HEAD.next; + if (strcmp(m->msg, "the number is 10") != 0) + return "the first message is incorrect"; + + m = m->next; + if (m == NULL) + return "there is not a second message!"; + + if (strcmp(m->msg, "the string is 'hello world'") != 0) + return "the second message is incorrect"; + + if (m->next != NULL) + return "too many messages"; + + lily_msg_destroy(lily_g.HEAD.next); + return 0; +} + + const char * test_CHECK() { lily_g.HEAD.next = NULL; diff --git a/tests/tests.h b/tests/tests.h index 06c35af..2942fa3 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -12,6 +12,7 @@ int validate_message(const char* received, const char* expected, X(test_LILY_COUNTER) \ X(test_LILY_COUNTER_DECREMENT) \ X(test_auto_registration) \ + X(test_INFO) \ X(test_CHECK) \ X(test_REQUIRE) \ -- cgit v1.2.1