diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-01-14 03:50:42 +0100 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2016-01-14 03:50:42 +0100 |
commit | f7aa4a3269a21f4d0c83f11a0aef4ccf821ce6e2 (patch) | |
tree | 9057cbd2b9eb61ec4bf57996b46d6faaf7844853 /tests/check_utils.c | |
parent | 5e53ba7406e65b51ec59aad634b6baf7154e1ad3 (diff) | |
download | blogc-f7aa4a3269a21f4d0c83f11a0aef4ccf821ce6e2.tar.gz blogc-f7aa4a3269a21f4d0c83f11a0aef4ccf821ce6e2.tar.bz2 blogc-f7aa4a3269a21f4d0c83f11a0aef4ccf821ce6e2.zip |
template-parser: added whitespace cleaners. needs more tests and docs
Diffstat (limited to 'tests/check_utils.c')
-rw-r--r-- | tests/check_utils.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/check_utils.c b/tests/check_utils.c index cb24625..a511dda 100644 --- a/tests/check_utils.c +++ b/tests/check_utils.c @@ -129,6 +129,50 @@ test_str_ends_with(void **state) static void +test_str_lstrip(void **state) +{ + char *str = b_strdup(" \tbola\n \t"); + assert_string_equal(b_str_lstrip(str), "bola\n \t"); + free(str); + str = b_strdup("guda"); + assert_string_equal(b_str_lstrip(str), "guda"); + free(str); + str = b_strdup("\n"); + assert_string_equal(b_str_lstrip(str), ""); + free(str); + str = b_strdup("\t \n"); + assert_string_equal(b_str_lstrip(str), ""); + free(str); + str = b_strdup(""); + assert_string_equal(b_str_lstrip(str), ""); + free(str); + assert_null(b_str_lstrip(NULL)); +} + + +static void +test_str_rstrip(void **state) +{ + char *str = b_strdup(" \tbola\n \t"); + assert_string_equal(b_str_rstrip(str), " \tbola"); + free(str); + str = b_strdup("guda"); + assert_string_equal(b_str_rstrip(str), "guda"); + free(str); + str = b_strdup("\n"); + assert_string_equal(b_str_rstrip(str), ""); + free(str); + str = b_strdup("\t \n"); + assert_string_equal(b_str_rstrip(str), ""); + free(str); + str = b_strdup(""); + assert_string_equal(b_str_rstrip(str), ""); + free(str); + assert_null(b_str_rstrip(NULL)); +} + + +static void test_str_strip(void **state) { char *str = b_strdup(" \tbola\n \t"); @@ -137,6 +181,15 @@ test_str_strip(void **state) str = b_strdup("guda"); assert_string_equal(b_str_strip(str), "guda"); free(str); + str = b_strdup("\n"); + assert_string_equal(b_str_strip(str), ""); + free(str); + str = b_strdup("\t \n"); + assert_string_equal(b_str_strip(str), ""); + free(str); + str = b_strdup(""); + assert_string_equal(b_str_strip(str), ""); + free(str); assert_null(b_str_strip(NULL)); } @@ -799,6 +852,8 @@ main(void) unit_test(test_strdup_printf), unit_test(test_str_starts_with), unit_test(test_str_ends_with), + unit_test(test_str_lstrip), + unit_test(test_str_rstrip), unit_test(test_str_strip), unit_test(test_str_split), unit_test(test_str_replace), |