Multiple Changes
This commit is contained in:
@@ -78,7 +78,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(EV_BUILDTYPE_DEBUG) && !defined(EV_BUILDTYPE_DEBUG_OPT) && !defined(EV_BUILDTYPE_RELEASE)
|
||||
#if !defined(EV_BUILDTYPE_DEBUG) && !defined(EV_BUILDTYPE_DEBUGOPT) && !defined(EV_BUILDTYPE_RELEASE)
|
||||
#define EV_BUILDTYPE_RELEASE 1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ evstring_free(
|
||||
{
|
||||
evstr_asserttype(s);
|
||||
if(META(s)->allocationType == EV_STR_ALLOCATION_TYPE_HEAP) {
|
||||
free(META(s));
|
||||
ev_str_free(META(s));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,9 +546,10 @@ __evstring_findFirst_impl(
|
||||
};
|
||||
|
||||
for(u64 i = text.offset; i < text.offset + text.len; i++) {
|
||||
if(text.data[i] == query.data[query.offset + found_progress]) {
|
||||
if(text.data[i] == query.data[query.offset + found_progress])
|
||||
found_progress++;
|
||||
}
|
||||
else
|
||||
found_progress = 0;
|
||||
if(found_progress == query.len) {
|
||||
result.offset = (i+1) - query.len;
|
||||
result.len = query.len;
|
||||
|
||||
@@ -43,6 +43,8 @@ headers_dep = declare_dependency(
|
||||
# Tests
|
||||
str_test = executable('str_test', 'str_test.c', dependencies: [str_dep], c_args: evh_c_args)
|
||||
test('evstr', str_test)
|
||||
vec_test = executable('vec_test', 'vec_test.c', dependencies: [vec_dep], c_args: evh_c_args)
|
||||
test('evvec', vec_test)
|
||||
log_test = executable('log_test', 'log_test.c', dependencies: [log_dep], c_args: evh_c_args)
|
||||
test('evlog', log_test)
|
||||
|
||||
|
||||
+25
@@ -77,5 +77,30 @@ int main()
|
||||
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;
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#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