summaryrefslogtreecommitdiff
path: root/tests/assertions.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assertions.c')
-rw-r--r--tests/assertions.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/assertions.c b/tests/assertions.c
index 6951f58..280bb97 100644
--- a/tests/assertions.c
+++ b/tests/assertions.c
@@ -149,6 +149,33 @@ const char * test_CHECK_EQS()
return 0;
}
+const char * test_CHECK_EQS_NULL()
+{
+ 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, NULL);
+ CHECK_EQS(a, "hi");
+
+ 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 == NULL\n a = \"hi\"\n NULL = \"(null)\""
+ ) != 0)
+ return "incorrect message";
+
+ lily_msg_destroy(lily_g.HEAD.next);
+ return 0;
+}
+
@@ -303,3 +330,40 @@ const char * test_REQUIRE_EQS()
return "test continued to run!";
}
}
+
+void f_test_REQUIRE_EQS_NULL()
+{
+ const char *a = "hi";
+ const char *b = "bye";
+ REQUIRE_EQS(a, NULL);
+ REQUIRE_EQS("hi hi"+3, a);
+}
+const char * test_REQUIRE_EQS_NULL()
+{
+ lily_g.HEAD.next = NULL;
+ lily_g.TAIL = &(lily_g.HEAD);
+ lily_g.failed = 0;
+ int test_failed = setjmp(lily_g.env);
+
+ if (test_failed) {
+ if (lily_g.HEAD.next == NULL)
+ return "REQUIRE_EQS did not append any failure message";
+
+ if (lily_g.HEAD.next->next != NULL)
+ return "REQUIRE_EQS appended more than one message";
+
+ if (strcmp(
+ lily_g.HEAD.next->msg,
+ "REQUIRE failed: a == NULL\n a = \"hi\"\n NULL = \"(null)\""
+ ) != 0)
+ return "incorrect message";
+
+ lily_msg_destroy(lily_g.HEAD.next);
+ return 0;
+ }
+ else {
+ f_test_REQUIRE_EQS_NULL();
+ return "test continued to run!";
+ }
+
+}