diff options
author | sanine <sanine.not@pm.me> | 2021-12-22 00:56:08 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-12-22 00:56:08 -0600 |
commit | 82009d685f48e95d58e0eaaf16f2bfc260e172ab (patch) | |
tree | 81d0e08861bb309946c02d0653a71df75de62096 /tests/assertions.c | |
parent | 46313b3265798ecf4cd6efedd3ef85caaa222cb4 (diff) |
add lily_assert_equal macro
Diffstat (limited to 'tests/assertions.c')
-rw-r--r-- | tests/assertions.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/assertions.c b/tests/assertions.c index 0c443b5..d95f52a 100644 --- a/tests/assertions.c +++ b/tests/assertions.c @@ -9,7 +9,7 @@ lily_test wrap_assert_msg(int statement, const char *message) { // 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, message); + lily_assert_msg(statement, 1, message, NULL); return LILY_SUCCESS; } @@ -29,3 +29,26 @@ const char* basic_assertion() 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!"; + + return 0; +} |