Moved tests + Added more tests + Added memory testing to actions
Run tests / Run tests (push) Failing after 6s

This commit is contained in:
2026-05-03 20:07:16 +03:00
parent b992f8c223
commit a4fa298d95
26 changed files with 386 additions and 143 deletions
+11
View File
@@ -0,0 +1,11 @@
tests = [
'zero_cap_grow',
'reducecap_updatelen',
'reducecap_free_elems',
'reducelen_free_elems',
]
foreach t : tests
exec = executable(t, t+'.c', dependencies: [vec_dep], c_args: evh_c_args)
test(t, exec, suite: 'vec')
endforeach
+28
View File
@@ -0,0 +1,28 @@
#define EV_VEC_IMPLEMENTATION
#include "ev_vec.h"
#include <assert.h>
static int free_calls = 0;
static void count_free(void *self)
{
(void)self;
free_calls++;
}
int main(void)
{
ev_vec(i32) v = ev_vec_init(i32, free = count_free);
assert(v != NULL);
for(i32 i = 0; i < 5; i++) {
assert(ev_vec_push_impl(&v, &i) >= 0);
}
free_calls = 0;
assert(ev_vec_setcapacity(&v, 3) == EV_VEC_ERR_NONE);
assert(free_calls == 2);
ev_vec_fini(&v);
}
+23
View File
@@ -0,0 +1,23 @@
#define EV_VEC_IMPLEMENTATION
#include "ev_vec.h"
#include <assert.h>
int main(void)
{
assert(EV_VEC_GROWTH_RATE > 1);
ev_vec(i32) v = ev_vec_init(i32);
assert(v != NULL);
for(i32 i = 0; i < 5; i++) {
assert(ev_vec_push_impl(&v, &i) >= 0);
}
ev_vec_error_t err = ev_vec_setcapacity(&v, 2);
assert(err != EV_VEC_ERR_NONE || ev_vec_len(&v) <= ev_vec_capacity(&v));
ev_vec_fini(&v);
return 0;
}
+25
View File
@@ -0,0 +1,25 @@
#define EV_VEC_IMPLEMENTATION
#include "ev_vec.h"
#include <assert.h>
static int free_calls = 0;
static void count_free(void *self)
{
(void)self;
free_calls++;
}
int main(void)
{
ev_vec(i32) v = ev_vec_init(i32, free = count_free);
assert(v != NULL);
free_calls = 0;
assert(ev_vec_setlen(&v, 3) == EV_VEC_ERR_NONE);
assert(ev_vec_setlen(&v, 1) == EV_VEC_ERR_NONE);
assert(free_calls == 2);
ev_vec_fini(&v);
}
+19
View File
@@ -0,0 +1,19 @@
#define EV_VEC_IMPLEMENTATION
#include "ev_vec.h"
#include <assert.h>
int main(void)
{
ev_vec(i32) v = ev_vec_init(i32);
assert(v != NULL);
assert(ev_vec_setcapacity(&v, 0) == EV_VEC_ERR_NONE);
assert(ev_vec_capacity(&v) == 0);
assert(ev_vec_grow(&v) == EV_VEC_ERR_NONE);
assert(ev_vec_capacity(&v) > 0);
ev_vec_fini(&v);
return 0;
}