30 lines
979 B
C
30 lines
979 B
C
#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;
|
|
}
|