|
@@ -34,12 +34,35 @@ void test_DynString_equal(void** state) {
|
|
|
DynString_free(&s2);
|
|
DynString_free(&s2);
|
|
|
|
|
|
|
|
s1 = DynString_alloc("Hello", strlen("Hello"));
|
|
s1 = DynString_alloc("Hello", strlen("Hello"));
|
|
|
|
|
+ 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"));
|
|
s2 = DynString_alloc("Hello", strlen("Hello"));
|
|
|
- assert_true(DynString_equal(&s1, &s2));
|
|
|
|
|
|
|
+ assert_false(DynString_equal(&s1, &s2));
|
|
|
DynString_free(&s1);
|
|
DynString_free(&s1);
|
|
|
DynString_free(&s2);
|
|
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) {
|
|
void test_DynString_concat_c_str(void** state) {
|
|
|
const char* dstr_c_str = "Hello";
|
|
const char* dstr_c_str = "Hello";
|
|
|
const char* c_str = " World";
|
|
const char* c_str = " World";
|
|
@@ -71,6 +94,7 @@ int main() {
|
|
|
cmocka_unit_test(test_DynString_alloc),
|
|
cmocka_unit_test(test_DynString_alloc),
|
|
|
cmocka_unit_test(test_DynString_free),
|
|
cmocka_unit_test(test_DynString_free),
|
|
|
cmocka_unit_test(test_DynString_equal),
|
|
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_concat_c_str),
|
|
|
cmocka_unit_test(test_DynString_c_str),
|
|
cmocka_unit_test(test_DynString_c_str),
|
|
|
};
|
|
};
|