DynString_equal_c_str

This commit is contained in:
2026-07-15 14:33:05 +03:00
parent 7a98eb4dfb
commit 61c76abf89
6 changed files with 53 additions and 17 deletions

View File

@@ -34,10 +34,33 @@ void test_DynString_equal(void** state) {
DynString_free(&s2);
s1 = DynString_alloc("Hello", strlen("Hello"));
s2 = DynString_alloc("Hello", strlen("Hello"));
assert_true(DynString_equal(&s1, &s2));
s2 = DynString_alloc("Hell0", strlen("Hell0"));
assert_false(DynString_equal(&s1, &s2));
DynString_free(&s1);
DynString_free(&s2);
s1 = DynString_alloc("Hello World", strlen("Hello World"));
s2 = DynString_alloc("Hello", strlen("Hello"));
assert_false(DynString_equal(&s1, &s2));
DynString_free(&s1);
DynString_free(&s2);
}
void test_DynString_equal_c_str(void** state) {
DynString s1 = DynString_alloc("Hello", strlen("Hello"));
char* s2 = "Hello";
assert_true(DynString_equal_c_str(&s1, s2));
DynString_free(&s1);
s1 = DynString_alloc("Hello", strlen("Hello"));
s2 = "Hell0";
assert_false(DynString_equal_c_str(&s1, s2));
DynString_free(&s1);
s1 = DynString_alloc("Hello World", strlen("Hello World"));
s2 = "Hello";
assert_false(DynString_equal_c_str(&s1, s2));
DynString_free(&s1);
}
void test_DynString_concat_c_str(void** state) {
@@ -71,6 +94,7 @@ int main() {
cmocka_unit_test(test_DynString_alloc),
cmocka_unit_test(test_DynString_free),
cmocka_unit_test(test_DynString_equal),
cmocka_unit_test(test_DynString_equal_c_str),
cmocka_unit_test(test_DynString_concat_c_str),
cmocka_unit_test(test_DynString_c_str),
};