summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-01-16 10:57:32 -0600
committersanine <sanine.not@pm.me>2022-01-16 10:57:32 -0600
commit2ff1af31412f5644bcf6f4747bbaafed96ca6122 (patch)
tree86cdc3ee45119c7a7d2940d6c0e7a63afd7b33b4
parent70fe832f3bfcf3fdff04772e1e9a96b4422ff2b3 (diff)
add test for lily_assert_ptr_not_equal
-rw-r--r--tests/assertions.c36
-rw-r--r--tests/main.c1
-rw-r--r--tests/tests.h1
3 files changed, 38 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;
+}
diff --git a/tests/main.c b/tests/main.c
index 6aaf1ed..b16e058 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -17,6 +17,7 @@ int main()
run_test(test_assert_not_null);
run_test(test_assert_null);
run_test(test_assert_ptr_equal);
+ run_test(test_assert_ptr_not_equal);
return 0;
}
diff --git a/tests/tests.h b/tests/tests.h
index 970d360..6a7d173 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -14,4 +14,5 @@ const char* test_assert_false();
const char* test_assert_not_null();
const char* test_assert_null();
const char* test_assert_ptr_equal();
+const char* test_assert_ptr_not_equal();
#endif