Added test case for pushFmt and added str_test as a meson unit test
Signed-off-by: Robear Selwans <robear.selwans@outlook.com>
This commit is contained in:
@@ -32,6 +32,10 @@ headers_dep = declare_dependency(
|
||||
]
|
||||
)
|
||||
|
||||
# Tests
|
||||
str_test = executable('str_test', 'str_test.c', dependencies: [str_dep])
|
||||
test('evstr', str_test)
|
||||
|
||||
if meson.version().version_compare('>= 0.54.0')
|
||||
meson.override_dependency('ev_vec', vec_dep)
|
||||
meson.override_dependency('ev_str', str_dep)
|
||||
|
||||
21
str_test.c
21
str_test.c
@@ -56,5 +56,26 @@ int main()
|
||||
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);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user