diff options
| author | Daniel Hader <[email protected]> | 2026-06-14 12:58:14 -0500 |
|---|---|---|
| committer | Daniel Hader <[email protected]> | 2026-06-14 12:58:14 -0500 |
| commit | 482ea0261cb9f0def49ce3df542b2a7f811262d1 (patch) | |
| tree | 3bb961316b2ca856409b9f3b2145036ae9f5d704 /test/test_vec.c | |
build and test environment using makefile and basic SDL3 setup
Diffstat (limited to 'test/test_vec.c')
| -rw-r--r-- | test/test_vec.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/test_vec.c b/test/test_vec.c new file mode 100644 index 0000000..a9788eb --- /dev/null +++ b/test/test_vec.c @@ -0,0 +1,31 @@ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include "util/alloc.h" +#include "util/vec.h" + +int main(int argc, char **argv) { + + struct LEO_Allocator allocator = { + malloc, + realloc, + free, + NULL + }; + + struct LEO_Vec vec; + assert(LEO_Vec_init(&vec, sizeof(int), allocator) == LEO_Vec_OK); + + for (int i = 0; i < 100; i++) { + assert(LEO_Vec_push(&vec, &i) == LEO_Vec_OK); + } + + for (int i = 0; i < 100; i++) { + int item; + assert(LEO_Vec_get(&vec, i, &item) == LEO_Vec_OK); + assert(item == i); + } + + LEO_Vec_free(&vec); + return 0; +} |
