summaryrefslogtreecommitdiff
path: root/tests/assertions.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assertions.c')
-rw-r--r--tests/assertions.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/assertions.c b/tests/assertions.c
index b19e9b3..4952943 100644
--- a/tests/assertions.c
+++ b/tests/assertions.c
@@ -205,3 +205,39 @@ const char *test_assert_ptr_equal()
return 0;
}
+
+
+const char *test_assert_ptr_not_equal()
+{
+ int a = 0;
+ int b = 0;
+ int *ptr = &b;
+
+ int val = setjmp(_lily_globals.env);
+ if (val != 0)
+ return "true assertion failed incorrectly!";
+
+ lily_assert_ptr_not_equal(&a, ptr);
+
+ int passed_thru = 0;
+ _lily_globals.error_msg = NULL;
+ _lily_globals.error_location = "";
+ val = setjmp(_lily_globals.env);
+ ptr = &a;
+
+ if (passed_thru == 0) {
+ passed_thru = 1;
+ lily_assert_ptr_not_equal(&a, ptr);
+ return "false assertion incorrectly succeeded!";
+ }
+ else {
+ char buf[256];
+ sprintf(buf, "&a (%p) is equal to ptr", &a);
+ if (strcmp(_lily_globals.error_msg, buf) != 0)
+ return "false assertion produced incorrect error message!";
+ if (strcmp(_lily_globals.error_location, "tests/assertions.c:230") != 0)
+ return "false assertion produced incorrect error location!";
+ }
+
+ return 0;
+}