summaryrefslogtreecommitdiff
path: root/lily-test.h
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2021-12-25 23:12:46 -0600
committersanine <sanine.not@pm.me>2021-12-25 23:12:46 -0600
commit9c4bd59002109c850dda3ab79febc17f7f0367e9 (patch)
tree78444546c972a4317cc7da0e20bdecb9101f7587 /lily-test.h
parent82009d685f48e95d58e0eaaf16f2bfc260e172ab (diff)
begin refactor to two-file library
Diffstat (limited to 'lily-test.h')
-rw-r--r--lily-test.h35
1 files changed, 6 insertions, 29 deletions
diff --git a/lily-test.h b/lily-test.h
index df50afb..c2f1b8b 100644
--- a/lily-test.h
+++ b/lily-test.h
@@ -1,44 +1,21 @@
#ifndef LILY_TEST_H
#define LILY_TEST_H
+#include <stdbool.h>
#include <stddef.h>
+#include <stdint.h>
-/* gives a string like 'some/filename:xxx' */
#define STR_IMP(x) #x
#define STR(x) STR_IMP(x)
/* define SOURCE_PATH_SIZE to strip away the
leading parts of the full compilation path */
#ifndef SOURCE_PATH_SIZE
-#define LILY_LOCATION "" __FILE__ ":" STR(__LINE__)
+#define LILY_LOCATION (__FILE__ ":" STR(__LINE__))
#else
-#define LILY_LOCATION (("" __FILE__ ":" STR(__LINE__)) + SOURCE_PATH_SIZE)
+#define LILY_LOCATION ((__FILE__ ":" STR(__LINE__)) + SOURCE_PATH_SIZE)
#endif
-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, NULL }
-
-// assertions
-#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)
+void lily_assert_printf(bool statement, const char *location,
+ const char *format_string, ...);
#endif