Add uc_dstr_copy

This commit is contained in:
Nils O. Selåsdal
2013-12-05 01:24:41 +01:00
parent 9723a579cc
commit 565de6ace7
3 changed files with 58 additions and 0 deletions
+28
View File
@@ -140,6 +140,33 @@ START_TEST (test_dstr_sprintf)
END_TEST
START_TEST (test_dstr_copy)
struct DStr str;
struct DStr copy;
size_t rc;
uc_dstr_init(&str);
rc = uc_dstr_put_str(&str, "123");
ck_assert_int_eq(rc, 0);
rc = uc_dstr_copy(&copy, &str);
ck_assert_int_eq(rc, 0);
ck_assert_str_eq(uc_dstr_str(&copy), uc_dstr_str(&str));
uc_dstr_destroy(&str);
uc_dstr_destroy(&copy);
uc_dstr_init(&str);
uc_dstr_init(&copy);
rc = uc_dstr_copy(&copy, &str);
ck_assert_int_eq(rc, 0);
ck_assert_str_eq(uc_dstr_str(&copy), "");
uc_dstr_destroy(&str);
uc_dstr_destroy(&copy);
END_TEST
Suite *dstr_suite(void)
{
Suite *s = suite_create("dstr");
@@ -150,6 +177,7 @@ Suite *dstr_suite(void)
tcase_add_test(tc, test_dstr_replace);
tcase_add_test(tc, test_dstr_filter);
tcase_add_test(tc, test_dstr_sprintf);
tcase_add_test(tc, test_dstr_copy);
suite_add_tcase(s, tc);