aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-25 20:34:58 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2018-07-25 22:28:41 +0200
commit008b956ba609bf30d8c6f44c36d9f11cdc493bc2 (patch)
tree69fac42a072944bd8eefaf4a4d04e185faef8b5e /tests
parente4c08cd44e37f28cd11d62a95f4791ace663c62d (diff)
downloadblogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.tar.gz
blogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.tar.bz2
blogc-008b956ba609bf30d8c6f44c36d9f11cdc493bc2.zip
common: added bc_str_to_bool
Diffstat (limited to 'tests')
-rw-r--r--tests/common/check_utils.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c
index 12ef921..90af37b 100644
--- a/tests/common/check_utils.c
+++ b/tests/common/check_utils.c
@@ -268,6 +268,31 @@ test_str_find(void **state)
static void
+test_str_to_bool(void **state)
+{
+ assert_false(bc_str_to_bool(NULL));
+ assert_true(bc_str_to_bool("1"));
+ assert_true(bc_str_to_bool("y"));
+ assert_true(bc_str_to_bool("Y"));
+ assert_true(bc_str_to_bool("yes"));
+ assert_true(bc_str_to_bool("YES"));
+ assert_true(bc_str_to_bool("true"));
+ assert_true(bc_str_to_bool("TRUE"));
+ assert_true(bc_str_to_bool("on"));
+ assert_true(bc_str_to_bool("ON"));
+ assert_false(bc_str_to_bool("0"));
+ assert_false(bc_str_to_bool("n"));
+ assert_false(bc_str_to_bool("N"));
+ assert_false(bc_str_to_bool("no"));
+ assert_false(bc_str_to_bool("NO"));
+ assert_false(bc_str_to_bool("false"));
+ assert_false(bc_str_to_bool("FALSE"));
+ assert_false(bc_str_to_bool("off"));
+ assert_false(bc_str_to_bool("OFF"));
+}
+
+
+static void
test_strv_join(void **state)
{
char *pieces[] = {"guda","bola", "chunda", NULL};
@@ -1039,6 +1064,7 @@ main(void)
unit_test(test_str_split),
unit_test(test_str_replace),
unit_test(test_str_find),
+ unit_test(test_str_to_bool),
unit_test(test_strv_join),
unit_test(test_strv_length),