diff options
| author | Mikhail Romanko <me@blankhex.com> | 2025-01-30 13:53:26 +0300 |
|---|---|---|
| committer | Mikhail Romanko <me@blankhex.com> | 2025-02-02 21:13:34 +0300 |
| commit | c89cf8f3165fa8c60b2d945716d071f390add973 (patch) | |
| tree | 89f1a7ff2a67ddc33c36d3283856904135761963 /unit/src/unit.c | |
| parent | 8d73a9b47335cad686da67c1f04ce50c84c601bd (diff) | |
| download | bhlib-c89cf8f3165fa8c60b2d945716d071f390add973.tar.gz | |
Change code and naming style, fix several bugs, removed math types.
After a while I felt that putting underscores between words was not the
best solution, so I changed the underscores to capital letters.
Fixed consistency bug between POSIX/Win32 platform in BH_FileOpen.
Removed definitions for math types (vector, matrix, etc.) due to
potential aliasing issues.
Diffstat (limited to 'unit/src/unit.c')
| -rwxr-xr-x | unit/src/unit.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/unit/src/unit.c b/unit/src/unit.c index a5f143c..6063a4f 100755 --- a/unit/src/unit.c +++ b/unit/src/unit.c @@ -1,27 +1,31 @@ #include <bh/unit.h> #include <stdlib.h> -typedef struct bh_unit_s +typedef struct BH_Unit { - struct bh_unit_s *next; + struct BH_Unit *next; const char *name; - bh_unit_cb_t func; -} bh_unit_t; + BH_UnitCallback cb; +} BH_Unit; -static bh_unit_t *root = NULL; -void bh_unit_add(const char *name, bh_unit_cb_t func) +static BH_Unit *root = NULL; + + +void BH_UnitAdd(const char *name, BH_UnitCallback cb) { - bh_unit_t *unit, *current; + BH_Unit *unit, *current; + /* Allocate and fill new unit test entry */ unit = malloc(sizeof(*unit)); if (!unit) return; - unit->name = name; - unit->func = func; unit->next = NULL; + unit->name = name; + unit->cb = cb; + /* Append unit test entry */ current = root; while (current && current->next) current = current->next; @@ -32,16 +36,17 @@ void bh_unit_add(const char *name, bh_unit_cb_t func) root = unit; } -int bh_unit_run(void) + +int BH_UnitRun(void) { - bh_unit_t *current; + BH_Unit *current; printf("Running tests...\n"); current = root; while (current) { printf("%s\n", current->name); - if (current->func()) + if (current->cb()) { printf("\tFAIL\n"); return -1; |
