summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/kit/allocator.c8
-rw-r--r--source/kit/allocator.h8
-rw-r--r--source/kit/array_ref.h15
-rw-r--r--source/kit/async_function.h2
-rw-r--r--source/kit/dynamic_array.c8
-rw-r--r--source/kit/dynamic_array.h48
-rw-r--r--source/kit/input_buffer.c62
-rw-r--r--source/kit/input_buffer.h15
-rw-r--r--source/kit/input_stream.c43
-rw-r--r--source/kit/input_stream.h16
-rw-r--r--source/kit/string_ref.h16
-rw-r--r--source/kit_test/run_tests.c2
-rw-r--r--source/kit_test/test.h79
-rw-r--r--source/test/unittests/input_buffer.test.c8
-rw-r--r--source/test/unittests/input_stream.test.c10
15 files changed, 169 insertions, 171 deletions
diff --git a/source/kit/allocator.c b/source/kit/allocator.c
index 115807c..1227002 100644
--- a/source/kit/allocator.c
+++ b/source/kit/allocator.c
@@ -18,9 +18,9 @@ static void deallocate(void *_, void *pointer) {
#endif
}
-struct kit_allocator kit_alloc_default() {
- struct kit_allocator alloc = { .state = NULL,
- .allocate = allocate,
- .deallocate = deallocate };
+kit_allocator_t kit_alloc_default() {
+ kit_allocator_t alloc = { .state = NULL,
+ .allocate = allocate,
+ .deallocate = deallocate };
return alloc;
}
diff --git a/source/kit/allocator.h b/source/kit/allocator.h
index 24ad5aa..4b91444 100644
--- a/source/kit/allocator.h
+++ b/source/kit/allocator.h
@@ -10,13 +10,13 @@ extern "C" {
typedef void *(*kit_allocate_fn)(void *state, size_t size);
typedef void (*kit_deallocate_fn)(void *state, void *pointer);
-struct kit_allocator {
- void *state;
+typedef struct {
+ void *state;
kit_allocate_fn allocate;
kit_deallocate_fn deallocate;
-};
+} kit_allocator_t;
-struct kit_allocator kit_alloc_default();
+kit_allocator_t kit_alloc_default();
#ifdef __cplusplus
}
diff --git a/source/kit/array_ref.h b/source/kit/array_ref.h
index 194faf7..b43db04 100644
--- a/source/kit/array_ref.h
+++ b/source/kit/array_ref.h
@@ -10,10 +10,9 @@ extern "C" {
typedef int (*kit_ar_compare_fn)(void const *left, void const *right);
int kit_ar_equal_bytes(ptrdiff_t left_element_size,
- ptrdiff_t left_size, void const *left_data,
- ptrdiff_t right_element_size,
- ptrdiff_t right_size,
- void const *right_data);
+ ptrdiff_t left_size, void const *left_data,
+ ptrdiff_t right_element_size,
+ ptrdiff_t right_size, void const *right_data);
int kit_ar_compare(ptrdiff_t left_element_size, ptrdiff_t left_size,
void const *left_data,
@@ -33,16 +32,16 @@ int kit_ar_compare(ptrdiff_t left_element_size, ptrdiff_t left_size,
} name_
#define KIT_AR_TYPE(name_, element_type_) \
- struct name_ { \
+ typedef struct { \
ptrdiff_t size; \
element_type_ *values; \
- }
+ } name_
#define KIT_AR_TYPE_CONST(name_, element_type_) \
- struct name_ { \
+ typedef struct { \
ptrdiff_t size; \
element_type_ const *values; \
- }
+ } name_
#define KIT_AR_EQUAL(left_, right_) \
kit_ar_equal_bytes(sizeof((left_).values[0]), (left_).size, \
diff --git a/source/kit/async_function.h b/source/kit/async_function.h
index 2d93726..b54ab63 100644
--- a/source/kit/async_function.h
+++ b/source/kit/async_function.h
@@ -5,7 +5,7 @@
extern "C" {
#endif
-enum kit_af_request {
+enum {
kit_af_request_execute = 0,
kit_af_request_resume = 1,
kit_af_request_join = 2,
diff --git a/source/kit/dynamic_array.c b/source/kit/dynamic_array.c
index f9d4405..3bda284 100644
--- a/source/kit/dynamic_array.c
+++ b/source/kit/dynamic_array.c
@@ -2,9 +2,9 @@
#include <string.h>
-void kit_da_init(struct kit_da_void *array, ptrdiff_t element_size,
- ptrdiff_t size, struct kit_allocator alloc) {
- memset(array, 0, sizeof(struct kit_da_void));
+void kit_da_init(kit_da_void_t *array, ptrdiff_t element_size,
+ ptrdiff_t size, kit_allocator_t alloc) {
+ memset(array, 0, sizeof(kit_da_void_t));
if (size > 0)
array->values = alloc.allocate(alloc.state, element_size * size);
@@ -26,7 +26,7 @@ static ptrdiff_t eval_capacity(ptrdiff_t current_cap,
return cap;
}
-void kit_da_resize(struct kit_da_void *array, ptrdiff_t element_size,
+void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
ptrdiff_t size) {
if (size <= array->capacity) {
array->size = size;
diff --git a/source/kit/dynamic_array.h b/source/kit/dynamic_array.h
index fde28dc..d9c3f87 100644
--- a/source/kit/dynamic_array.h
+++ b/source/kit/dynamic_array.h
@@ -7,43 +7,43 @@
extern "C" {
#endif
-struct kit_da_void {
- ptrdiff_t capacity;
- ptrdiff_t size;
- void *values;
- struct kit_allocator alloc;
-};
+typedef struct {
+ ptrdiff_t capacity;
+ ptrdiff_t size;
+ void *values;
+ kit_allocator_t alloc;
+} kit_da_void_t;
-void kit_da_init(struct kit_da_void *array, ptrdiff_t element_size,
- ptrdiff_t size, struct kit_allocator alloc);
+void kit_da_init(kit_da_void_t *array, ptrdiff_t element_size,
+ ptrdiff_t size, kit_allocator_t alloc);
-void kit_da_resize(struct kit_da_void *array, ptrdiff_t element_size,
+void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
ptrdiff_t size);
/* Declare dynamic array type.
*/
#define KIT_DA_TYPE(name_, element_type_) \
- struct name_ { \
- ptrdiff_t capacity; \
- ptrdiff_t size; \
- element_type_ *values; \
- struct kit_allocator alloc; \
- }
+ typedef struct { \
+ ptrdiff_t capacity; \
+ ptrdiff_t size; \
+ element_type_ *values; \
+ kit_allocator_t alloc; \
+ } name_
/* Declare dynamic array.
*/
#define KIT_DA(name_, element_type_) \
struct { \
- ptrdiff_t capacity; \
- ptrdiff_t size; \
- element_type_ *values; \
- struct kit_allocator alloc; \
+ ptrdiff_t capacity; \
+ ptrdiff_t size; \
+ element_type_ *values; \
+ kit_allocator_t alloc; \
} name_
/* Initialize dynamic array.
*/
-#define KIT_DA_INIT(array_, size_, alloc_) \
- kit_da_init((struct kit_da_void *) &(array_), \
+#define KIT_DA_INIT(array_, size_, alloc_) \
+ kit_da_init((kit_da_void_t *) &(array_), \
sizeof((array_).values[0]), (size_), (alloc_))
/* Declare and initialize dynamic array.
@@ -63,8 +63,8 @@ void kit_da_resize(struct kit_da_void *array, ptrdiff_t element_size,
/* Resize dynamic array.
*/
-#define KIT_DA_RESIZE(array_, size_) \
- kit_da_resize((struct kit_da_void *) &(array_), \
+#define KIT_DA_RESIZE(array_, size_) \
+ kit_da_resize((kit_da_void_t *) &(array_), \
sizeof((array_).values[0]), size_)
/* Append a value to dynamic array.
@@ -102,7 +102,7 @@ void kit_da_resize(struct kit_da_void *array, ptrdiff_t element_size,
}
#ifndef KIT_DISABLE_SHORT_NAMES
-# define da_void kit_da_void
+# define da_void_t kit_da_void_t
# define da_init kit_da_init
# define da_resize kit_da_resize
diff --git a/source/kit/input_buffer.c b/source/kit/input_buffer.c
index 6b4d24c..2f3bd07 100644
--- a/source/kit/input_buffer.c
+++ b/source/kit/input_buffer.c
@@ -2,16 +2,16 @@
#include <string.h>
-struct internal_buffer {
- ptrdiff_t ref_count;
- struct kit_is_handle upstream;
- struct kit_allocator alloc;
+typedef struct {
+ ptrdiff_t ref_count;
+ kit_is_handle_t upstream;
+ kit_allocator_t alloc;
DA(data, char);
-};
+} internal_buffer_t;
-static struct internal_buffer *buf_init(struct kit_is_handle upstream,
- struct kit_allocator alloc) {
- struct internal_buffer *buf;
+static internal_buffer_t *buf_init(kit_is_handle_t upstream,
+ kit_allocator_t alloc) {
+ internal_buffer_t *buf;
buf = alloc.allocate(alloc.state, sizeof *buf);
if (buf != NULL) {
memset(buf, 0, sizeof *buf);
@@ -23,17 +23,17 @@ static struct internal_buffer *buf_init(struct kit_is_handle upstream,
return buf;
}
-static struct kit_allocator buf_alloc(void *p) {
- return ((struct internal_buffer *) p)->alloc;
+static kit_allocator_t buf_alloc(void *p) {
+ return ((internal_buffer_t *) p)->alloc;
}
static void buf_acquire(void *p) {
- struct internal_buffer *buf = (struct internal_buffer *) p;
+ internal_buffer_t *buf = (internal_buffer_t *) p;
buf->ref_count++;
}
static void buf_release(void *p) {
- struct internal_buffer *buf = (struct internal_buffer *) p;
+ internal_buffer_t *buf = (internal_buffer_t *) p;
if (--buf->ref_count == 0) {
DA_DESTROY(buf->data);
buf->alloc.deallocate(buf->alloc.state, buf);
@@ -41,13 +41,14 @@ static void buf_release(void *p) {
}
static void buf_adjust(void *p, ptrdiff_t size) {
- struct internal_buffer *buf = (struct internal_buffer *) p;
- ptrdiff_t offset = buf->data.size;
+ internal_buffer_t *buf = (internal_buffer_t *) p;
+ ptrdiff_t offset = buf->data.size;
if (offset < size) {
DA_RESIZE(buf->data, size);
- kit_out_str destination = { .size = size - offset,
- .values = buf->data.values + offset };
- ptrdiff_t n = KIT_IS_READ(buf->upstream, destination);
+ kit_out_str_t destination = {
+ .size = size - offset, .values = buf->data.values + offset
+ };
+ ptrdiff_t n = KIT_IS_READ(buf->upstream, destination);
DA_RESIZE(buf->data, offset + n);
}
}
@@ -59,16 +60,16 @@ static ptrdiff_t min(ptrdiff_t a, ptrdiff_t b) {
}
static ptrdiff_t buf_read(void *p, ptrdiff_t offset,
- kit_out_str destination) {
- struct internal_buffer *buf = (struct internal_buffer *) p;
+ kit_out_str_t destination) {
+ internal_buffer_t *buf = (internal_buffer_t *) p;
ptrdiff_t n = min(destination.size, buf->data.size - offset);
memcpy(destination.values, buf->data.values + offset, n);
return n;
}
-struct kit_ib_handle kit_ib_wrap(struct kit_is_handle upstream,
- struct kit_allocator alloc) {
- struct kit_ib_handle buf;
+kit_ib_handle_t kit_ib_wrap(kit_is_handle_t upstream,
+ kit_allocator_t alloc) {
+ kit_ib_handle_t buf;
memset(&buf, 0, sizeof buf);
buf.error = 0;
DA_INIT(buf.data, 0, alloc);
@@ -78,9 +79,8 @@ struct kit_ib_handle kit_ib_wrap(struct kit_is_handle upstream,
return buf;
}
-struct kit_ib_handle kit_ib_read(struct kit_ib_handle buf,
- ptrdiff_t size) {
- struct kit_ib_handle next;
+kit_ib_handle_t kit_ib_read(kit_ib_handle_t buf, ptrdiff_t size) {
+ kit_ib_handle_t next;
memset(&next, 0, sizeof next);
if (buf.error) {
next.error = 1;
@@ -90,11 +90,11 @@ struct kit_ib_handle kit_ib_read(struct kit_ib_handle buf,
DA_INIT(next.data, size, buf_alloc(buf.internal));
if (next.data.size != size)
next.error = 1;
- kit_out_str destination = { .size = next.data.size,
- .values = next.data.values };
- ptrdiff_t n = buf_read(buf.internal, buf.offset, destination);
- next.offset = buf.offset + n;
- next.internal = buf.internal;
+ kit_out_str_t destination = { .size = next.data.size,
+ .values = next.data.values };
+ ptrdiff_t n = buf_read(buf.internal, buf.offset, destination);
+ next.offset = buf.offset + n;
+ next.internal = buf.internal;
DA_RESIZE(next.data, n);
if (next.data.size != n)
next.error = 1;
@@ -102,7 +102,7 @@ struct kit_ib_handle kit_ib_read(struct kit_ib_handle buf,
return next;
}
-void kit_ib_destroy(struct kit_ib_handle buf) {
+void kit_ib_destroy(kit_ib_handle_t buf) {
buf_release(buf.internal);
DA_DESTROY(buf.data);
}
diff --git a/source/kit/input_buffer.h b/source/kit/input_buffer.h
index 4ebffdf..4e62f83 100644
--- a/source/kit/input_buffer.h
+++ b/source/kit/input_buffer.h
@@ -8,26 +8,25 @@
extern "C" {
#endif
-struct kit_ib_handle {
+typedef struct {
int error;
ptrdiff_t offset;
void *internal;
DA(data, char);
-};
+} kit_ib_handle_t;
-struct kit_ib_handle kit_ib_wrap(struct kit_is_handle upstream,
- struct kit_allocator alloc);
+kit_ib_handle_t kit_ib_wrap(kit_is_handle_t upstream,
+ kit_allocator_t alloc);
-struct kit_ib_handle kit_ib_read(struct kit_ib_handle buf,
- ptrdiff_t size);
+kit_ib_handle_t kit_ib_read(kit_ib_handle_t buf, ptrdiff_t size);
-void kit_ib_destroy(struct kit_ib_handle buf);
+void kit_ib_destroy(kit_ib_handle_t buf);
#define KIT_IB_WRAP(upstream) \
kit_ib_wrap(upstream, kit_alloc_default())
#ifndef KIT_DISABLE_SHORT_NAMES
-# define ib_handle kit_ib_handle
+# define ib_handle_t kit_ib_handle_t
# define ib_wrap kit_ib_wrap
# define ib_read kit_ib_read
# define ib_destroy kit_ib_destroy
diff --git a/source/kit/input_stream.c b/source/kit/input_stream.c
index 186e96c..1eaf5eb 100644
--- a/source/kit/input_stream.c
+++ b/source/kit/input_stream.c
@@ -2,22 +2,21 @@
#include <string.h>
-enum input_stream_type { input_stream_cstr };
+enum { input_stream_cstr };
-struct kit_is_state_basic {
- ptrdiff_t type;
- struct kit_allocator alloc;
-};
+typedef struct {
+ ptrdiff_t type;
+ kit_allocator_t alloc;
+} kit_is_state_basic_t;
-struct kit_is_state_cstr {
- ptrdiff_t type;
- struct kit_allocator alloc;
- kit_cstr string;
-};
+typedef struct {
+ ptrdiff_t type;
+ kit_allocator_t alloc;
+ kit_cstr_t string;
+} kit_is_state_cstr_t;
static _Bool check_type(void *state, ptrdiff_t type) {
- struct kit_is_state_basic *basic = (struct kit_is_state_basic *)
- state;
+ kit_is_state_basic_t *basic = (kit_is_state_basic_t *) state;
return basic != NULL && basic->type == type;
}
@@ -27,10 +26,10 @@ static ptrdiff_t min(ptrdiff_t a, ptrdiff_t b) {
return b;
}
-static ptrdiff_t read_cstr(void *state, kit_out_str destination) {
+static ptrdiff_t read_cstr(void *state, kit_out_str_t destination) {
if (!check_type(state, input_stream_cstr))
return 0;
- struct kit_is_state_cstr *cstr = (struct kit_is_state_cstr *) state;
+ kit_is_state_cstr_t *cstr = (kit_is_state_cstr_t *) state;
ptrdiff_t size = min(destination.size, cstr->string.size);
memcpy(destination.values, cstr->string.values, size);
cstr->string.values += size;
@@ -38,13 +37,12 @@ static ptrdiff_t read_cstr(void *state, kit_out_str destination) {
return size;
}
-struct kit_is_handle kit_is_wrap_string(kit_cstr string,
- struct kit_allocator alloc) {
- struct kit_is_handle in;
+kit_is_handle_t kit_is_wrap_string(kit_cstr_t string,
+ kit_allocator_t alloc) {
+ kit_is_handle_t in;
memset(&in, 0, sizeof in);
- struct kit_is_state_cstr *state =
- (struct kit_is_state_cstr *) alloc.allocate(
- alloc.state, sizeof(struct kit_is_state_cstr));
+ kit_is_state_cstr_t *state = (kit_is_state_cstr_t *) alloc.allocate(
+ alloc.state, sizeof(kit_is_state_cstr_t));
if (state != NULL) {
memset(state, 0, sizeof *state);
state->type = input_stream_cstr;
@@ -56,9 +54,8 @@ struct kit_is_handle kit_is_wrap_string(kit_cstr string,
return in;
}
-void kit_is_destroy(struct kit_is_handle in) {
- struct kit_is_state_basic *basic = (struct kit_is_state_basic *)
- in.state;
+void kit_is_destroy(kit_is_handle_t in) {
+ kit_is_state_basic_t *basic = (kit_is_state_basic_t *) in.state;
if (basic != NULL)
basic->alloc.deallocate(basic->alloc.state, in.state);
}
diff --git a/source/kit/input_stream.h b/source/kit/input_stream.h
index a0d00e7..90321f4 100644
--- a/source/kit/input_stream.h
+++ b/source/kit/input_stream.h
@@ -8,18 +8,18 @@
extern "C" {
#endif
-typedef ptrdiff_t (*kit_is_read_fn)(void *state,
- kit_out_str destination);
+typedef ptrdiff_t (*kit_is_read_fn)(void *state,
+ kit_out_str_t destination);
-struct kit_is_handle {
+typedef struct {
void *state;
kit_is_read_fn read;
-};
+} kit_is_handle_t;
-struct kit_is_handle kit_is_wrap_string(kit_cstr string,
- struct kit_allocator alloc);
+kit_is_handle_t kit_is_wrap_string(kit_cstr_t string,
+ kit_allocator_t alloc);
-void kit_is_destroy(struct kit_is_handle in);
+void kit_is_destroy(kit_is_handle_t in);
#define KIT_IS_WRAP_STRING(string) \
kit_is_wrap_string((string), kit_alloc_default())
@@ -29,7 +29,7 @@ void kit_is_destroy(struct kit_is_handle in);
#ifndef KIT_DISABLE_SHORT_NAMES
# define is_read_fn kit_is_read_fn
-# define is_handle kit_is_handle
+# define is_handle_t kit_is_handle_t
# define is_wrap_string kit_is_wrap_string
# define is_destroy kit_is_destroy
diff --git a/source/kit/string_ref.h b/source/kit/string_ref.h
index 19206dc..79a023b 100644
--- a/source/kit/string_ref.h
+++ b/source/kit/string_ref.h
@@ -7,17 +7,17 @@
extern "C" {
#endif
-KIT_AR_TYPE(kit_string_ref, char);
-KIT_AR_TYPE_CONST(kit_string_cref, char);
+KIT_AR_TYPE(kit_string_ref_t, char);
+KIT_AR_TYPE_CONST(kit_string_cref_t, char);
-typedef struct kit_string_ref kit_out_str;
-typedef struct kit_string_cref kit_cstr;
+typedef kit_string_ref_t kit_out_str_t;
+typedef kit_string_cref_t kit_cstr_t;
#ifndef KIT_DISABLE_SHORT_NAMES
-# define string_ref kit_string_ref
-# define string_cref kit_string_cref
-# define out_str kit_out_str
-# define cstr kit_cstr
+# define string_ref_t kit_string_ref_t
+# define string_cref_t kit_string_cref_t
+# define out_str_t kit_out_str_t
+# define cstr_t kit_cstr_t
#endif
#ifdef __cplusplus
diff --git a/source/kit_test/run_tests.c b/source/kit_test/run_tests.c
index 6694c52..1cb391c 100644
--- a/source/kit_test/run_tests.c
+++ b/source/kit_test/run_tests.c
@@ -3,7 +3,7 @@
#include <stdio.h>
#include <time.h>
-struct kit_tests_list kit_tests_list = { 0 };
+kit_tests_list_t kit_tests_list = { 0 };
static void report(int i, char const *file, int line, int ok) {
int const n = kit_tests_list.tests[i].assertions++;
diff --git a/source/kit_test/test.h b/source/kit_test/test.h
index 37abb9f..fdbfbdc 100644
--- a/source/kit_test/test.h
+++ b/source/kit_test/test.h
@@ -24,24 +24,25 @@ extern "C" {
# define KIT_TEST_STRING_SIZE 0x100
#endif
-typedef void (*kit_test_report)(int, char const *file, int line, int);
-typedef void (*kit_test_function)(int, kit_test_report);
-
-struct kit_test_case {
- char test_name[KIT_TEST_STRING_SIZE];
- kit_test_function test_fn;
- int assertions;
- char const *file[KIT_TEST_ASSERTIONS_LIMIT];
- int line[KIT_TEST_ASSERTIONS_LIMIT];
- int status[KIT_TEST_ASSERTIONS_LIMIT];
-};
-
-struct kit_tests_list {
- int size;
- struct kit_test_case tests[KIT_TESTS_SIZE_LIMIT];
-};
-
-extern struct kit_tests_list kit_tests_list;
+typedef void (*kit_test_report_fn)(int, char const *file, int line,
+ int ok);
+typedef void (*kit_test_run_fn)(int, kit_test_report_fn);
+
+typedef struct {
+ char test_name[KIT_TEST_STRING_SIZE];
+ kit_test_run_fn test_fn;
+ int assertions;
+ char const *file[KIT_TEST_ASSERTIONS_LIMIT];
+ int line[KIT_TEST_ASSERTIONS_LIMIT];
+ int status[KIT_TEST_ASSERTIONS_LIMIT];
+} kit_test_case_t;
+
+typedef struct {
+ int size;
+ kit_test_case_t tests[KIT_TESTS_SIZE_LIMIT];
+} kit_tests_list_t;
+
+extern kit_tests_list_t kit_tests_list;
#define KIT_TEST_CONCAT4_(a, b, c, d) a##b##c##d
#define KIT_TEST_CONCAT3_(a, b, c) KIT_TEST_CONCAT4_(a, b, _, c)
@@ -78,26 +79,28 @@ extern struct kit_tests_list kit_tests_list;
# endif
#endif
-#define KIT_TEST(name) \
- static void KIT_TEST_CONCAT3_( \
- kit_test_run_, __LINE__, KIT_TEST_FILE)(int, kit_test_report); \
- KIT_TEST_ON_START_( \
- KIT_TEST_CONCAT3_(kit_test_case_, __LINE__, KIT_TEST_FILE)) { \
- int n = kit_tests_list.size; \
- if (n < KIT_TESTS_SIZE_LIMIT) { \
- kit_tests_list.size++; \
- kit_tests_list.tests[n].test_fn = KIT_TEST_CONCAT3_( \
- kit_test_run_, __LINE__, KIT_TEST_FILE); \
- strcpy(kit_tests_list.tests[n].test_name, name); \
- kit_tests_list.tests[n].assertions = 0; \
- } \
- } \
- static void KIT_TEST_CONCAT3_(kit_test_run_, __LINE__, \
- KIT_TEST_FILE)( \
- int kit_test_index_, kit_test_report kit_test_report_)
-
-#define KIT_REQUIRE(...) \
- kit_test_report_(kit_test_index_, __FILE__, __LINE__, (__VA_ARGS__))
+#define KIT_TEST(name) \
+ static void KIT_TEST_CONCAT3_(kit_test_run_, __LINE__, \
+ KIT_TEST_FILE)(int, \
+ kit_test_report_fn); \
+ KIT_TEST_ON_START_( \
+ KIT_TEST_CONCAT3_(kit_test_case_, __LINE__, KIT_TEST_FILE)) { \
+ int n = kit_tests_list.size; \
+ if (n < KIT_TESTS_SIZE_LIMIT) { \
+ kit_tests_list.size++; \
+ kit_tests_list.tests[n].test_fn = KIT_TEST_CONCAT3_( \
+ kit_test_run_, __LINE__, KIT_TEST_FILE); \
+ strcpy(kit_tests_list.tests[n].test_name, name); \
+ kit_tests_list.tests[n].assertions = 0; \
+ } \
+ } \
+ static void KIT_TEST_CONCAT3_(kit_test_run_, __LINE__, \
+ KIT_TEST_FILE)( \
+ int kit_test_index_, kit_test_report_fn kit_test_report_fn_)
+
+#define KIT_REQUIRE(...) \
+ kit_test_report_fn_(kit_test_index_, __FILE__, __LINE__, \
+ (__VA_ARGS__))
int kit_run_tests(int argc, char **argv);
diff --git a/source/test/unittests/input_buffer.test.c b/source/test/unittests/input_buffer.test.c
index c7edb8f..23499ee 100644
--- a/source/test/unittests/input_buffer.test.c
+++ b/source/test/unittests/input_buffer.test.c
@@ -4,11 +4,11 @@
#include "../../kit_test/test.h"
TEST("input buffer") {
- cstr text = { .size = 3, .values = "foo" };
- struct is_handle in = IS_WRAP_STRING(text);
- struct ib_handle first = IB_WRAP(in);
+ cstr_t text = { .size = 3, .values = "foo" };
+ is_handle_t in = IS_WRAP_STRING(text);
+ ib_handle_t first = IB_WRAP(in);
- struct ib_handle second = ib_read(first, 3);
+ ib_handle_t second = ib_read(first, 3);
REQUIRE(!second.error);
REQUIRE(second.data.size == 3);
diff --git a/source/test/unittests/input_stream.test.c b/source/test/unittests/input_stream.test.c
index 9fef47a..e646983 100644
--- a/source/test/unittests/input_stream.test.c
+++ b/source/test/unittests/input_stream.test.c
@@ -7,13 +7,13 @@ TEST("input stream wrap string") {
char foo[] = "test";
char bar[] = "test";
- cstr foo_ref = { .size = sizeof(foo) - 1, .values = foo };
- cstr bar_ref = { .size = sizeof(bar) - 1, .values = bar };
+ cstr_t foo_ref = { .size = sizeof(foo) - 1, .values = foo };
+ cstr_t bar_ref = { .size = sizeof(bar) - 1, .values = bar };
- struct is_handle in = IS_WRAP_STRING(foo_ref);
+ is_handle_t in = IS_WRAP_STRING(foo_ref);
- char buf[4];
- out_str buf_ref = { .size = sizeof(buf), .values = buf };
+ char buf[4];
+ out_str_t buf_ref = { .size = sizeof(buf), .values = buf };
REQUIRE(IS_READ(in, buf_ref) == buf_ref.size);
REQUIRE(AR_EQUAL(foo_ref, bar_ref));