Moved tests + Added more tests + Added memory testing to actions
Run tests / Run tests (push) Failing after 6s
Run tests / Run tests (push) Failing after 6s
This commit is contained in:
@@ -13,9 +13,13 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: meson setup build
|
run: meson setup build
|
||||||
- name: Run tests
|
|
||||||
|
- name: Run Tests
|
||||||
run: meson test -C build
|
run: meson test -C build
|
||||||
|
|
||||||
|
- name: Run Memory Tests
|
||||||
|
run: meson test -C build --wrapper=valgrind
|
||||||
|
|
||||||
- name: Upload Meson Logs
|
- name: Upload Meson Logs
|
||||||
if: always()
|
if: always()
|
||||||
uses: christopherHX/gitea-upload-artifact@v4
|
uses: christopherHX/gitea-upload-artifact@v4
|
||||||
|
|||||||
+8
-14
@@ -40,18 +40,12 @@ headers_dep = declare_dependency(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
# Tests
|
meson.override_dependency('ev_vec', vec_dep)
|
||||||
str_test = executable('str_test', 'str_test.c', dependencies: [str_dep], c_args: evh_c_args)
|
meson.override_dependency('ev_str', str_dep)
|
||||||
test('evstr', str_test)
|
meson.override_dependency('ev_helpers', helpers_dep)
|
||||||
vec_test = executable('vec_test', 'vec_test.c', dependencies: [vec_dep], c_args: evh_c_args)
|
meson.override_dependency('ev_log', log_dep)
|
||||||
test('evvec', vec_test)
|
meson.override_dependency('evol-headers', headers_dep)
|
||||||
log_test = executable('log_test', 'log_test.c', dependencies: [log_dep], c_args: evh_c_args)
|
|
||||||
test('evlog', log_test)
|
|
||||||
|
|
||||||
if meson.version().version_compare('>= 0.54.0')
|
# if build_tests
|
||||||
meson.override_dependency('ev_vec', vec_dep)
|
subdir('tests')
|
||||||
meson.override_dependency('ev_str', str_dep)
|
#endif
|
||||||
meson.override_dependency('ev_helpers', helpers_dep)
|
|
||||||
meson.override_dependency('ev_log', log_dep)
|
|
||||||
meson.override_dependency('evol-headers', headers_dep)
|
|
||||||
endif
|
|
||||||
|
|||||||
-106
@@ -1,106 +0,0 @@
|
|||||||
#define EV_STR_IMPLEMENTATION
|
|
||||||
#include "ev_str.h"
|
|
||||||
|
|
||||||
evstring global_str = evstr("Global 'Hello, World!'");
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
const evstring stack_str = evstr("Stack 'Hello, World!'");
|
|
||||||
printf("Stack String: %s, Length: %llu\n", stack_str, evstring_getLength(stack_str));
|
|
||||||
printf("Global String: %s, Length: %llu\n", global_str, evstring_getLength(global_str));
|
|
||||||
|
|
||||||
evstring heap_str = evstring_new("Heap 'Hello, World!'");
|
|
||||||
printf("Heap String: %s, Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
|
|
||||||
evstring_view view = evstring_slice(stack_str, 0, -1);
|
|
||||||
printf("String View: %.*s\n", (i32)view.len, view.data + view.offset);
|
|
||||||
printf("View length: %llu\n", view.len);
|
|
||||||
|
|
||||||
evstring heap_str2 = evstring_new(view);
|
|
||||||
printf("Heap String 2: %s, Length: %llu\n", heap_str2, evstring_getLength(heap_str2));
|
|
||||||
evstring_free(heap_str2);
|
|
||||||
|
|
||||||
|
|
||||||
evstring_error_t push_str_res = evstring_push(&heap_str, "Hello, Sisyphus! %f", 0.001f);
|
|
||||||
printf("Push char*: %s, New Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
assert(push_str_res == EV_STR_ERR_NONE);
|
|
||||||
|
|
||||||
evstring_error_t push_char_res = evstring_push(&heap_str, (char)'X');
|
|
||||||
printf("Push char: %s, New Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
assert(push_char_res == EV_STR_ERR_NONE);
|
|
||||||
|
|
||||||
evstring_error_t push_view_res = evstring_push(&heap_str, view);
|
|
||||||
printf("Push view: %s, New Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
assert(push_view_res == EV_STR_ERR_NONE);
|
|
||||||
|
|
||||||
evstring str_fmt = evstring_new("%d, %d, %.*s", 1, 0, view.len, view.data + view.offset);
|
|
||||||
printf("Formatted String: %s\n", str_fmt);
|
|
||||||
|
|
||||||
evstring rep_str = evstring_replaceFirst(heap_str, evstr("Hello"), evstr("Bye"));
|
|
||||||
printf("Replaced String: %s\n", rep_str);
|
|
||||||
evstring_free(rep_str);
|
|
||||||
|
|
||||||
evstring_free(str_fmt);
|
|
||||||
evstring_free(heap_str);
|
|
||||||
|
|
||||||
evstring_view search_results[8];
|
|
||||||
evstring search_string = evstr("Hello, this is me saying `Hello` like someone who says 'Hello'");
|
|
||||||
assert(evstring_findAll(search_string, evstr("Hello"), search_results) == 3);
|
|
||||||
assert(search_results[0].data == search_string);
|
|
||||||
assert(search_results[1].data == search_string);
|
|
||||||
assert(search_results[2].data == search_string);
|
|
||||||
assert(search_results[0].len == 5);
|
|
||||||
assert(search_results[1].len == 5);
|
|
||||||
assert(search_results[2].len == 5);
|
|
||||||
assert(search_results[0].offset == 0);
|
|
||||||
assert(search_results[1].offset == 26);
|
|
||||||
assert(search_results[2].offset == 56);
|
|
||||||
|
|
||||||
{ // PushFmt Bug
|
|
||||||
printf("PushFmt Bug");
|
|
||||||
evstring heap_str = evstring_new("Heap 'Hello, World!'");
|
|
||||||
printf("Heap String: %s, Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
|
|
||||||
evstring_error_t res = evstring_push(&heap_str, "%.05f", 1.0f);
|
|
||||||
printf("Push Fmt #1: %s, New Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
assert(evstring_getLength(heap_str) == 27);
|
|
||||||
assert(strcmp(heap_str, "Heap 'Hello, World!'1.00000") == 0);
|
|
||||||
assert(res == EV_STR_ERR_NONE);
|
|
||||||
|
|
||||||
/*evstring_push(&heap_str, "%.05f, %.05f, %.05f", 1.0f, 2.0f, 3.0f);*/
|
|
||||||
res = evstring_push(&heap_str, "Something");
|
|
||||||
printf("Push Fmt #2: %s, New Length: %llu\n", heap_str, evstring_getLength(heap_str));
|
|
||||||
assert(evstring_getLength(heap_str) == 36);
|
|
||||||
assert(strcmp(heap_str, "Heap 'Hello, World!'1.00000Something") == 0);
|
|
||||||
assert(res == EV_STR_ERR_NONE);
|
|
||||||
|
|
||||||
evstring_free(heap_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Incorrectly handled mismatches
|
|
||||||
evstring text = evstr("aab");
|
|
||||||
evstring query = evstr("ab");
|
|
||||||
evstring_view match = evstring_findFirst(text, query);
|
|
||||||
assert(match.len == 2);
|
|
||||||
assert(match.offset == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Underflowing getSpace for stack strings
|
|
||||||
evstring stack_str = evstr("abc");
|
|
||||||
assert(evstring_getSpace(stack_str) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
{ // Overlapping push
|
|
||||||
evstring s = evstring_newFromStr("abc");
|
|
||||||
assert(s != NULL);
|
|
||||||
|
|
||||||
evstring_error_t err = evstring_pushStr(&s, s);
|
|
||||||
assert(err == EV_STR_ERR_NONE);
|
|
||||||
assert(strcmp(s, "abcabc") == 0);
|
|
||||||
|
|
||||||
evstring_free(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
tests = [
|
||||||
|
'basic_log',
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach t : tests
|
||||||
|
exec = executable(t, t+'.c', dependencies: [log_dep], c_args: evh_c_args)
|
||||||
|
test(t, exec, suite: 'log')
|
||||||
|
endforeach
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring_view search_results[8];
|
||||||
|
evstring search_string = evstr("Hello, this is me saying `Hello` like someone who says 'Hello'");
|
||||||
|
|
||||||
|
assert(evstring_findAll(search_string, evstr("Hello"), search_results) == 3);
|
||||||
|
assert(search_results[0].data == search_string);
|
||||||
|
assert(search_results[1].data == search_string);
|
||||||
|
assert(search_results[2].data == search_string);
|
||||||
|
assert(search_results[0].len == 5);
|
||||||
|
assert(search_results[1].len == 5);
|
||||||
|
assert(search_results[2].len == 5);
|
||||||
|
assert(search_results[0].offset == 0);
|
||||||
|
assert(search_results[1].offset == 26);
|
||||||
|
assert(search_results[2].offset == 56);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring text = evstr("aab");
|
||||||
|
evstring query = evstr("ab");
|
||||||
|
evstring_view match = evstring_findFirst(text, query);
|
||||||
|
|
||||||
|
assert(match.len == 2);
|
||||||
|
assert(match.offset == 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring text = evstr("aaab");
|
||||||
|
evstring query = evstr("aab");
|
||||||
|
evstring_view match = evstring_findFirst(text, query);
|
||||||
|
|
||||||
|
assert(match.len == 3);
|
||||||
|
assert(match.offset == 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
tests = [
|
||||||
|
'stack_global_heap',
|
||||||
|
'slice',
|
||||||
|
'push_variants',
|
||||||
|
'new_format',
|
||||||
|
'replace_first',
|
||||||
|
'find_all',
|
||||||
|
'push_fmt_float',
|
||||||
|
'find_first_mismatch',
|
||||||
|
'find_first_overlapping_prefix',
|
||||||
|
'stack_get_space',
|
||||||
|
'overlapping_push',
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach t : tests
|
||||||
|
exec = executable(t, t+'.c', dependencies: [str_dep], c_args: evh_c_args)
|
||||||
|
test(t, exec, suite: 'str')
|
||||||
|
endforeach
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring source = evstr("Stack 'Hello, World!'");
|
||||||
|
evstring_view view = evstring_slice(source, 0, -1);
|
||||||
|
|
||||||
|
evstring str_fmt = evstring_new("%d, %d, %.*s", 1, 0, view.len, view.data + view.offset);
|
||||||
|
assert(str_fmt != NULL);
|
||||||
|
assert(strcmp(str_fmt, "1, 0, Stack 'Hello, World!'") == 0);
|
||||||
|
|
||||||
|
evstring_free(str_fmt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring s = evstring_newFromStr("abc");
|
||||||
|
assert(s != NULL);
|
||||||
|
|
||||||
|
evstring_error_t err = evstring_pushStr(&s, s);
|
||||||
|
assert(err == EV_STR_ERR_NONE);
|
||||||
|
assert(strcmp(s, "abcabc") == 0);
|
||||||
|
|
||||||
|
evstring_free(s);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring heap_str = evstring_new("Heap 'Hello, World!'");
|
||||||
|
assert(heap_str != NULL);
|
||||||
|
|
||||||
|
evstring_error_t res = evstring_push(&heap_str, "%.05f", 1.0f);
|
||||||
|
assert(res == EV_STR_ERR_NONE);
|
||||||
|
assert(evstring_getLength(heap_str) == 27);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'1.00000") == 0);
|
||||||
|
|
||||||
|
res = evstring_push(&heap_str, "Something");
|
||||||
|
assert(res == EV_STR_ERR_NONE);
|
||||||
|
assert(evstring_getLength(heap_str) == 36);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'1.00000Something") == 0);
|
||||||
|
|
||||||
|
evstring_free(heap_str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring heap_str = evstring_new("Heap 'Hello, World!'");
|
||||||
|
assert(heap_str != NULL);
|
||||||
|
|
||||||
|
evstring_error_t push_str_res = evstring_push(&heap_str, "Hello, Sisyphus! %f", 0.001f);
|
||||||
|
assert(push_str_res == EV_STR_ERR_NONE);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'Hello, Sisyphus! 0.001000") == 0);
|
||||||
|
|
||||||
|
evstring_error_t push_char_res = evstring_push(&heap_str, (char)'X');
|
||||||
|
assert(push_char_res == EV_STR_ERR_NONE);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'Hello, Sisyphus! 0.001000X") == 0);
|
||||||
|
|
||||||
|
evstring source = evstr("Stack 'Hello, World!'");
|
||||||
|
evstring_view view = evstring_slice(source, 0, -1);
|
||||||
|
evstring_error_t push_view_res = evstring_push(&heap_str, view);
|
||||||
|
assert(push_view_res == EV_STR_ERR_NONE);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'Hello, Sisyphus! 0.001000XStack 'Hello, World!'") == 0);
|
||||||
|
|
||||||
|
evstring_free(heap_str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring text = evstring_new("Hello, Hello!");
|
||||||
|
assert(text != NULL);
|
||||||
|
|
||||||
|
evstring rep_str = evstring_replaceFirst(text, evstr("Hello"), evstr("Bye"));
|
||||||
|
assert(rep_str != NULL);
|
||||||
|
assert(strcmp(rep_str, "Bye, Hello!") == 0);
|
||||||
|
|
||||||
|
evstring_free(rep_str);
|
||||||
|
evstring_free(text);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const evstring stack_str = evstr("Stack 'Hello, World!'");
|
||||||
|
|
||||||
|
evstring_view view = evstring_slice(stack_str, 0, -1);
|
||||||
|
assert(view.data == stack_str);
|
||||||
|
assert(view.offset == 0);
|
||||||
|
assert(view.len == evstring_getLength(stack_str));
|
||||||
|
|
||||||
|
evstring heap_str = evstring_new(view);
|
||||||
|
assert(heap_str != NULL);
|
||||||
|
assert(strcmp(heap_str, stack_str) == 0);
|
||||||
|
assert(evstring_getLength(heap_str) == evstring_getLength(stack_str));
|
||||||
|
|
||||||
|
evstring_free(heap_str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
evstring stack_str = evstr("abc");
|
||||||
|
assert(evstring_getSpace(stack_str) == 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#define EV_STR_IMPLEMENTATION
|
||||||
|
#include "ev_str.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static evstring global_str = evstr("Global 'Hello, World!'");
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
const evstring stack_str = evstr("Stack 'Hello, World!'");
|
||||||
|
assert(strcmp(stack_str, "Stack 'Hello, World!'") == 0);
|
||||||
|
assert(evstring_getLength(stack_str) == 21);
|
||||||
|
|
||||||
|
assert(strcmp(global_str, "Global 'Hello, World!'") == 0);
|
||||||
|
assert(evstring_getLength(global_str) == 22);
|
||||||
|
|
||||||
|
evstring heap_str = evstring_new("Heap 'Hello, World!'");
|
||||||
|
assert(heap_str != NULL);
|
||||||
|
assert(strcmp(heap_str, "Heap 'Hello, World!'") == 0);
|
||||||
|
assert(evstring_getLength(heap_str) == 20);
|
||||||
|
|
||||||
|
evstring_free(heap_str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
tests = [
|
||||||
|
'tostr',
|
||||||
|
]
|
||||||
|
|
||||||
|
foreach t : tests
|
||||||
|
exec = executable(t, t+'.c', include_directories: headers_include, c_args: evh_c_args)
|
||||||
|
test(t, exec, suite: 'types')
|
||||||
|
endforeach
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
subdir('ev_log')
|
||||||
|
subdir('ev_str')
|
||||||
|
subdir('ev_types')
|
||||||
|
subdir('ev_vec')
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
#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);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user