summaryrefslogtreecommitdiff
path: root/tests/assertions.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/assertions.c')
-rw-r--r--tests/assertions.c50
1 files changed, 6 insertions, 44 deletions
diff --git a/tests/assertions.c b/tests/assertions.c
index d95f52a..5fb5e8d 100644
--- a/tests/assertions.c
+++ b/tests/assertions.c
@@ -4,51 +4,13 @@
#include "lily-test.h"
#include "tests.h"
-// basic assertion
-lily_test wrap_assert_msg(int statement, const char *message)
+const char *test_LILY_LOCATION()
{
- // if you move the location of this line, BE SURE TO UPDATE THE
- // TEST BELOW so that it expects the correct line!
- lily_assert_msg(statement, 1, message, NULL);
- return LILY_SUCCESS;
-}
-
-const char* basic_assertion()
-{
- lily_test result = wrap_assert_msg(1, "should succeed");
- if (result.error != 0)
- return "assert_msg() incorrectly returned non-zero error on true statement!";
-
- result = wrap_assert_msg(0, "should fail");
- if (result.error == 0)
- return "assert_msg() incorrectly returned zero error on false statement!";
- if (strcmp(result.message, "should fail") != 0)
- return "assert_msg() returned with incorrect message!";
- if (strcmp(result.location, "tests/assertions.c:12") != 0)
- return "assert_msg() returned with incorrect location!";
-
- return 0;
-}
-
-
-// assert equal
-lily_test wrap_assert_equal(int x, int y)
-{
- lily_assert_equal(x, y);
- return LILY_SUCCESS;
-}
-
-const char* assert_equal()
-{
- lily_test result = wrap_assert_equal(15, 15);
- if (result.error != LILY_NO_ERROR)
- return "lily_assert_equal incorrectly returned an error on equal inputs!";
-
- result = wrap_assert_equal(14, 15);
- if (result.error != LILY_NULL_DATA)
- return "lily_assert_equal returned an incorrect error on non-equal inputs!";
- if (strcmp(result.message, "x is not equal to y") != 0)
- return "lily_assert_equal returned incorrect message for non-equal inputs!";
+ // if you move this line, you MUST update the expected string!
+ const char *location = LILY_LOCATION;
+ int diff = strcmp(location, "tests/assertions.c:10");
+ if (diff != 0)
+ return "LILY_LOCATION did not resolve correctly!";
return 0;
}