Add uc_strv_reverse
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user