Add uc_strv_reverse

This commit is contained in:
Nils O. Selåsdal
2015-12-10 19:13:16 +01:00
parent 9b70b64729
commit db78689015
3 changed files with 55 additions and 0 deletions
+39
View File
@@ -123,6 +123,44 @@ START_TEST (test_strv_append_all_nocopy)
END_TEST
START_TEST (test_strv_reverse)
struct UCStrv strv;
uc_strv_init(&strv);
uc_strv_append(&strv, "string1");
uc_strv_reverse(&strv);
ck_assert_str_eq("string1", strv.strings[0]);
uc_strv_destroy(&strv);
uc_strv_init(&strv);
uc_strv_append(&strv, "string1");
uc_strv_append(&strv, "string2");
uc_strv_reverse(&strv);
ck_assert_str_eq("string2", strv.strings[0]);
ck_assert_str_eq("string1", strv.strings[1]);
uc_strv_destroy(&strv);
uc_strv_init(&strv);
uc_strv_append(&strv, "string1");
uc_strv_append(&strv, "string2");
uc_strv_append(&strv, "string3");
uc_strv_reverse(&strv);
ck_assert_str_eq("string3", strv.strings[0]);
ck_assert_str_eq("string2", strv.strings[1]);
ck_assert_str_eq("string1", strv.strings[2]);
uc_strv_destroy(&strv);
END_TEST
Suite *strv_suite(void)
{
@@ -135,6 +173,7 @@ Suite *strv_suite(void)
tcase_add_test(tc, test_strv_null_terminate);
tcase_add_test(tc, test_strv_append_all_copy);
tcase_add_test(tc, test_strv_append_all_nocopy);
tcase_add_test(tc, test_strv_reverse);
suite_add_tcase(s, tc);