aboutsummaryrefslogtreecommitdiffstats
path: root/tests/check_utils.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-01-30 22:45:46 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-01-30 22:45:46 +0100
commitc4d19f731dc683c5a65327d99f2b416d4781f00b (patch)
tree09e8941c5ac840b2a74ca28e5a474b7746e5fe79 /tests/check_utils.c
parent008c96d6518125f2683c1b4e842ca3ed6e865c3d (diff)
parent3b0ea0a4908f1702308354ec7cbd8db5c80f87ee (diff)
downloadblogc-c4d19f731dc683c5a65327d99f2b416d4781f00b.tar.gz
blogc-c4d19f731dc683c5a65327d99f2b416d4781f00b.tar.bz2
blogc-c4d19f731dc683c5a65327d99f2b416d4781f00b.zip
Merge remote-tracking branch 'origin/master' into feature/directives
Diffstat (limited to 'tests/check_utils.c')
-rw-r--r--tests/check_utils.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/check_utils.c b/tests/check_utils.c
index a42c75a..a511dda 100644
--- a/tests/check_utils.c
+++ b/tests/check_utils.c
@@ -1,6 +1,6 @@
/*
* blogc: A blog compiler.
- * Copyright (C) 2014-2015 Rafael G. Martins <rafael@rafaelmartins.eng.br>
+ * Copyright (C) 2014-2016 Rafael G. Martins <rafael@rafaelmartins.eng.br>
*
* This program can be distributed under the terms of the BSD License.
* See the file LICENSE.
@@ -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),