diff options
author | sanine <sanine.not@pm.me> | 2022-12-31 13:52:55 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-12-31 13:52:55 -0600 |
commit | 8f2536a0d2e653cb393eb81292ce4d029129d404 (patch) | |
tree | 4dad74c5cb0f1af550fe723eb1c133ec4270d936 /tests/assertions.c | |
parent | bf71f069d4861ba2285c96dd98bdf1bbe0322fc2 (diff) |
modify error message format and add CHECK_EQF
Diffstat (limited to 'tests/assertions.c')
-rw-r--r-- | tests/assertions.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/assertions.c b/tests/assertions.c index 39db7bd..6d0c0e1 100644 --- a/tests/assertions.c +++ b/tests/assertions.c @@ -87,7 +87,34 @@ const char * test_CHECK_EQ() 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) + if (strcmp(lily_g.HEAD.next->msg, "CHECK failed: 4 == k\n 4 = 04\n k = 05") != 0) + return "incorrect message"; + + lily_msg_destroy(lily_g.HEAD.next); + return 0; +} + + +const char * test_CHECK_EQF() +{ + lily_g.HEAD.next = NULL; + lily_g.TAIL = &(lily_g.HEAD); + lily_g.failed = 0; + + lily_set_epsilon(0.2); + CHECK_EQF(0.5, 0.4, "%0.1f"); + CHECK_EQF(0.5, 0.0, "%0.1f"); + + if (lily_g.HEAD.next == NULL) + return "CHECK_EQF did not append any failure message"; + + if (lily_g.HEAD.next->next != NULL) + return "CHECK_EQF appended more than one message"; + + if (strcmp( + lily_g.HEAD.next->msg, + "CHECK failed: 0.5 == 0.0\n 0.5 = 0.5\n 0.0 = 0.0\n epsilon: 0.200000" + ) != 0) return "incorrect message"; lily_msg_destroy(lily_g.HEAD.next); @@ -158,7 +185,7 @@ const char * test_REQUIRE_EQ() if (lily_g.HEAD.next == NULL) return "test did not generate any messages"; - if (strcmp(lily_g.HEAD.next->msg, "REQUIRE failed: 2 == 4 (2 == 4)") != 0) + if (strcmp(lily_g.HEAD.next->msg, "REQUIRE failed: 2 == 4\n 2 = 2\n 4 = 4") != 0) return "test generated incorrect message"; if (lily_g.HEAD.next->next != NULL) |