feat: add tests

This commit is contained in:
2025-09-07 17:35:30 +02:00
parent be154db6cf
commit 3e0584d139
10 changed files with 165 additions and 129 deletions

27
test/string/str2.c Normal file
View File

@@ -0,0 +1,27 @@
#include <assert.h>
#include <string.h>
#include "../../string/mystring.h"
void test_str2(void) {
mcl_string_s *s1 = mcl_string_new("Hello, world!", 0);
assert(s1 != NULL);
mcl_string_s *s2 = mcl_string_new("Hello, world!", 0);
assert(s2 != NULL);
/* Don't call mcl_string_cstr() more than once in the same printf function */
int ret = mcl_string_compare(s1, s2);
assert(ret == 0);
mcl_string_clear(s1);
ret = mcl_string_compare(s1, s2);
assert(ret != 0);
mcl_string_tolower(s1);
mcl_string_toupper(s2);
assert(strcmp(mcl_string_cstr(s1), "") == 0);
assert(strcmp(mcl_string_cstr(s2), "HELLO, WORLD!") == 0);
mcl_string_free(s1);
mcl_string_free(s2);
}