This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring text = evstr("Hello, this is me saying `Hello` like someone who says 'Hello'");
|
||||
|
||||
assert(evstring_findAll(text, evstr("Hello"), NULL) == 3);
|
||||
assert(evstring_findAll(evstr("abc"), evstr("abc"), NULL) == 1);
|
||||
assert(evstring_findAll(evstr("abcx"), evstr("abc"), NULL) == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring_view search_results[1];
|
||||
evstring text = evstr("abc");
|
||||
evstring query = evstr("abc");
|
||||
|
||||
assert(evstring_findAll(text, query, search_results) == 1);
|
||||
assert(search_results[0].data == text);
|
||||
assert(search_results[0].len == 3);
|
||||
assert(search_results[0].offset == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring_view search_results[1];
|
||||
evstring text = evstr("Hello, this is me saying `Hello` like someone who says 'Hello'");
|
||||
|
||||
assert(evstring_findAll(text, evstr(""), search_results) == 0);
|
||||
assert(evstring_findAll(text, evstr("Goodbye"), search_results) == 0);
|
||||
assert(evstring_findAll(evstr("ab"), evstr("abc"), search_results) == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring_view search_results[2];
|
||||
evstring text = evstr("aaa");
|
||||
evstring query = evstr("aa");
|
||||
|
||||
assert(evstring_findAll(text, query, search_results) == 2);
|
||||
|
||||
assert(search_results[0].data == text);
|
||||
assert(search_results[0].len == 2);
|
||||
assert(search_results[0].offset == 0);
|
||||
|
||||
assert(search_results[1].data == text);
|
||||
assert(search_results[1].len == 2);
|
||||
assert(search_results[1].offset == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring_view search_results[1];
|
||||
evstring text = evstr("abcx");
|
||||
evstring query = evstr("abc");
|
||||
|
||||
assert(evstring_findAll(text, query, search_results) == 1);
|
||||
assert(search_results[0].data == text);
|
||||
assert(search_results[0].len == 3);
|
||||
assert(search_results[0].offset == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring text = evstr("");
|
||||
evstring query = evstr("a");
|
||||
|
||||
evstring_view match = evstring_findFirst(text, query);
|
||||
|
||||
assert(match.len == 0);
|
||||
assert(match.offset == ~0ull);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring text = evstr("ab");
|
||||
evstring query = evstr("abc");
|
||||
|
||||
evstring_view match = evstring_findFirst(text, query);
|
||||
|
||||
assert(match.len == 0);
|
||||
assert(match.offset == ~0ull);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,12 +5,20 @@ tests = [
|
||||
'new_format',
|
||||
'replace_first',
|
||||
'find_all',
|
||||
'find_all_exact_match',
|
||||
'find_all_short_suffix',
|
||||
'find_all_count_only',
|
||||
'find_all_no_matches',
|
||||
'find_all_overlapping',
|
||||
'push_fmt_float',
|
||||
'find_first_mismatch',
|
||||
'find_first_overlapping_prefix',
|
||||
'stack_get_space',
|
||||
'overlapping_push',
|
||||
'find_first_empty_query',
|
||||
'find_first_query_too_long',
|
||||
'find_first_empty_text',
|
||||
'replace_first_query_too_long',
|
||||
]
|
||||
|
||||
foreach t : tests
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#define EV_STR_IMPLEMENTATION
|
||||
#include "ev_str.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
evstring text = evstr("ab");
|
||||
evstring replacement = evstr("x");
|
||||
evstring query = evstr("abc");
|
||||
|
||||
evstring result = evstring_replaceFirst(text, query, replacement);
|
||||
|
||||
assert(EV_EQUAL(evstring)(&result, &text));
|
||||
|
||||
evstring_free(result);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user