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 /lily-test.h | |
parent | 46313b3265798ecf4cd6efedd3ef85caaa222cb4 (diff) |
add lily_assert_equal macro
Diffstat (limited to 'lily-test.h')
-rw-r--r-- | lily-test.h | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lily-test.h b/lily-test.h index 1894127..df50afb 100644 --- a/lily-test.h +++ b/lily-test.h @@ -18,16 +18,27 @@ struct lily_test_result_t { int error; const char *message; const char *location; + void *data; }; typedef struct lily_test_result_t lily_test; -#define LILY_SUCCESS (struct lily_test_result_t){ 0, NULL, NULL } +#define LILY_SUCCESS (struct lily_test_result_t){ 0, NULL, NULL, NULL } // assertions -#define lily_assert_msg(statement, message) do { \ - if(!(statement)) { \ - return (struct lily_test_result_t){1, (message), LILY_LOCATION}; \ - } \ +#define LILY_NO_ERROR 0 +#define LILY_NULL_DATA 1 +#define LILY_INT_DATA 2 +#define LILY_STRING_DATA 3 + +#define lily_assert_msg(statement, code, message, data) do { \ + if(!(statement)) { \ + return (struct lily_test_result_t){ \ + (code), (message), LILY_LOCATION, (data) \ + }; \ + } \ } while(0) +#define lily_assert_equal(a, b) \ + lily_assert_msg(a == b, LILY_NULL_DATA, #a " is not equal to " #b, NULL) + #endif |