diff options
author | sanine <sanine.not@pm.me> | 2022-04-04 12:39:36 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-04-04 12:39:36 -0500 |
commit | c4619e22d571bffa75ab033fceda7915c676f90d (patch) | |
tree | 0cd8adba7f52335c147d83847232b043b6f39666 /lily-test.h | |
parent | abe324281121925be29c98f32d19a187a7e3f53f (diff) |
add basic mock queue + test
Diffstat (limited to 'lily-test.h')
-rw-r--r-- | lily-test.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lily-test.h b/lily-test.h index de69e92..783e134 100644 --- a/lily-test.h +++ b/lily-test.h @@ -18,6 +18,7 @@ struct lily_globals_t { jmp_buf env; + size_t error_msg_len; char *error_msg; const char *error_location; }; @@ -25,6 +26,14 @@ struct lily_globals_t { extern struct lily_globals_t _lily_globals; void lily_init(); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * assertions + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + void lily_assert_msg(bool statement, const char *location, const char *format_string, ...); @@ -97,4 +106,35 @@ void _lily_assert_memory_equal(const char *name_a, const char *name_b, void _lily_assert_memory_not_equal(const char *name_a, const char *name_b, void *a, void *b, size_t size, const char *location); + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * mocks + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ + +typedef struct lily_mock_queue_t { + size_t buf_size; + uint8_t *buf; + uint8_t *front, *back; +} lily_mock_queue_t; + + +lily_mock_queue_t* lily_queue_create(); +void lily_queue_destroy(lily_mock_queue_t *q); + +#define lily_enqueue(q, type, value) \ + do { \ + type _var = value; \ + _lily_enqueue(q, sizeof(type), (uint8_t*)(&_var)); \ + } while(0) +void _lily_enqueue(lily_mock_queue_t *q, size_t size, uint8_t *data); + + +#define lily_dequeue(q, type, ptr) \ + _lily_dequeue(q, sizeof(type), (uint8_t*) ptr) +void _lily_dequeue(lily_mock_queue_t *q, size_t size, uint8_t *ptr); + + #endif |