From 590b2997f93006112be93807b7e7a36d56d52809 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 31 Dec 2022 14:00:24 -0600 Subject: add CHECK_EQS --- tests/assertions.c | 30 ++++++++++++++++++++++++++++++ tests/tests.h | 1 + 2 files changed, 31 insertions(+) (limited to 'tests') diff --git a/tests/assertions.c b/tests/assertions.c index 6d0c0e1..e79ae44 100644 --- a/tests/assertions.c +++ b/tests/assertions.c @@ -122,6 +122,36 @@ const char * test_CHECK_EQF() } +const char * test_CHECK_EQS() +{ + lily_g.HEAD.next = NULL; + lily_g.TAIL = &(lily_g.HEAD); + lily_g.failed = 0; + + const char *a = "hi"; + const char *b = "bye"; + CHECK_EQS(a, b); + CHECK_EQS("hi hi"+3, a); + + if (lily_g.HEAD.next == NULL) + return "CHECK_EQS did not append any failure message"; + + if (lily_g.HEAD.next->next != NULL) + return "CHECK_EQS appended more than one message"; + + if (strcmp( + lily_g.HEAD.next->msg, + "CHECK failed: a == b\n a = \"hi\"\n b = \"bye\"" + ) != 0) + return "incorrect message"; + + lily_msg_destroy(lily_g.HEAD.next); + return 0; +} + + + + int aR, bR; static void f_test_REQUIRE() { diff --git a/tests/tests.h b/tests/tests.h index 631044e..d6d95d1 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -16,6 +16,7 @@ int validate_message(const char* received, const char* expected, X(test_CHECK) \ X(test_CHECK_EQ) \ X(test_CHECK_EQF) \ + X(test_CHECK_EQS) \ X(test_REQUIRE) \ X(test_REQUIRE_EQ) \ -- cgit v1.2.1