test: move all module tests to the test/ directory

This commit is contained in:
2025-11-01 10:12:18 +00:00
parent a68b9f7ba7
commit bd2fe50ec9
32 changed files with 5 additions and 5 deletions

50
test/ds/ds-units.c Normal file
View File

@@ -0,0 +1,50 @@
#include <CuTest.h>
#include <blue/ds/string.h>
static void test_string_create(CuTest *tc)
{
b_string *str = b_string_create();
CuAssertPtrNotNull(tc, str);
CuAssertIntEquals(tc, 0, b_string_get_size(str, B_STRLEN_NORMAL));
CuAssertStrEquals(tc, "", b_string_ptr(str));
b_string_unref(str);
str = b_string_create_from_c('A', 8);
CuAssertPtrNotNull(tc, str);
CuAssertIntEquals(tc, 8, b_string_get_size(str, B_STRLEN_NORMAL));
CuAssertStrEquals(tc, "AAAAAAAA", b_string_ptr(str));
b_string_unref(str);
str = b_string_create_from_cstr("Hello, world!");
CuAssertPtrNotNull(tc, str);
CuAssertIntEquals(tc, 13, b_string_get_size(str, B_STRLEN_NORMAL));
CuAssertStrEquals(tc, "Hello, world!", b_string_ptr(str));
b_string_unref(str);
}
static void test_string_length(CuTest *tc)
{
const char *cstr = "Hello, \033[91;1mworld!";
b_string *s = b_string_create_from_cstr(cstr);
CuAssertIntEquals(tc, 13, b_string_get_size(s, B_STRLEN_IGNORE_ESC));
CuAssertIntEquals(tc, 20, b_string_get_size(s, B_STRLEN_NORMAL));
b_string_unref(s);
}
CuSuite *get_all_tests(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_string_create);
SUITE_ADD_TEST(suite, test_string_length);
return suite;
}