summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-12-21 20:11:30 -0600
committersanine <sanine.not@pm.me>2022-12-21 20:11:30 -0600
commit423082adc4b8d0e8964ca73e79ed7d9ac8b391a3 (patch)
tree7842320ed549e6487daa4c14070cfd2416e8731a /tests
parent182b4002e63f330de6150e160a1ad23b1e6b33b8 (diff)
add example
Diffstat (limited to 'tests')
-rw-r--r--tests/assertions.c30
-rw-r--r--tests/tests.h1
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/assertions.c b/tests/assertions.c
index 156a484..5a32854 100644
--- a/tests/assertions.c
+++ b/tests/assertions.c
@@ -49,14 +49,14 @@ const char * test_CHECK()
return "CHECK did not append any failure messages";
lily_test_msg_t *m = lily_g.HEAD.next;
- if (strcmp(m->msg, "1 == 0") != 0)
+ if (strcmp(m->msg, "CHECK failed: 1 == 0") != 0)
return "first assert has wrong message";
if (m->next == NULL)
return "only one message appended";
m = m->next;
- if (strcmp(m->msg, "4 == 3") != 0)
+ if (strcmp(m->msg, "CHECK failed: 4 == 3") != 0)
return "second message is incorrect";
if (m->next != NULL)
@@ -71,6 +71,30 @@ const char * test_CHECK()
}
+const char * test_CHECK_EQ()
+{
+ lily_g.HEAD.next = NULL;
+ lily_g.TAIL = &(lily_g.HEAD);
+ lily_g.failed = 0;
+
+ int k = 5;
+ CHECK_EQ(k, 5, "%d");
+ CHECK_EQ(4, k, "%02d");
+
+ if (lily_g.HEAD.next == NULL)
+ return "CHECK_EQ did not append any failure message";
+
+ if (lily_g.HEAD.next->next != NULL)
+ return "CHECK_EQ appended more than one message";
+
+ if (strcmp(lily_g.HEAD.next->msg, "CHECK failed: 4 == k (04 == 05)") != 0)
+ return "incorrect message";
+
+ lily_msg_destroy(lily_g.HEAD.next);
+ return 0;
+}
+
+
int aR, bR;
static void f_test_REQUIRE()
{
@@ -94,7 +118,7 @@ const char * test_REQUIRE()
if (lily_g.HEAD.next == NULL)
return "test did not generate any messages";
- if (strcmp(lily_g.HEAD.next->msg, "2+2 == 5") != 0)
+ if (strcmp(lily_g.HEAD.next->msg, "REQUIRE failed: 2+2 == 5") != 0)
return "test generated incorrect message";
if (lily_g.HEAD.next->next != NULL)
diff --git a/tests/tests.h b/tests/tests.h
index 2942fa3..393da87 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -14,6 +14,7 @@ int validate_message(const char* received, const char* expected,
X(test_auto_registration) \
X(test_INFO) \
X(test_CHECK) \
+ X(test_CHECK_EQ) \
X(test_REQUIRE) \
#define X(test) const char * test();