mirror of
https://github.com/Tilo-K/tstd.git
synced 2026-01-10 06:51:01 +00:00
feat: add contains functions
This commit is contained in:
@@ -51,6 +51,20 @@ int test_delete_element() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_list_contains() {
|
||||
list* list = list_create();
|
||||
list_add_element(list, "Hello");
|
||||
list_add_element(list, "World");
|
||||
list_add_element(list, "Test");
|
||||
|
||||
assert(list_contains(list, "Hello") == 1);
|
||||
assert(list_contains(list, "World") == 1);
|
||||
assert(list_contains(list, "Test") == 1);
|
||||
assert(list_contains(list, "Other") == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int result = 0;
|
||||
|
||||
@@ -58,6 +72,7 @@ int main() {
|
||||
result += test_list_add_element();
|
||||
result += test_add_multiple_elements();
|
||||
result += test_delete_element();
|
||||
result += test_list_contains();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ int test_split_function_by_substring() {
|
||||
const size_t size = str_split_by_substring(test_str, "split", &parts);
|
||||
assert(parts != NULL);
|
||||
|
||||
printf("size: %llu\n", size);
|
||||
printf("size: %lu\n", size);
|
||||
|
||||
assert(size == 4);
|
||||
assert(strcmp(parts[0], "this") == 0);
|
||||
@@ -112,6 +112,15 @@ int test_trim() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_string_contains() {
|
||||
char* test_str = "Hello, test. test";
|
||||
assert(str_contains(test_str, "Hello") == 1);
|
||||
assert(str_contains(test_str, "test") == 1);
|
||||
assert(str_contains(test_str, "World") == 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_string_functions() {
|
||||
int result = 0;
|
||||
|
||||
@@ -123,10 +132,12 @@ int test_string_functions() {
|
||||
result += test_string_to_lower();
|
||||
result += test_string_concat();
|
||||
result += test_trim();
|
||||
result += test_string_contains();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
return test_string_functions();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user