Browse Source

tests: Add utils_parse_bool_str test

Signed-off-by: Jan Friesse <jfriesse@redhat.com>

(cherry picked from corosync-qdevice project commit
 00713d41fa797812f725a2eb37055a9bf49ad165)
Jan Friesse 6 years ago
parent
commit
1e2ced94e0
1 changed files with 16 additions and 1 deletions
  1. 16 1
      qdevices/test-utils.c

+ 16 - 1
qdevices/test-utils.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2015-2018 Red Hat, Inc.
+ * Copyright (c) 2015-2019 Red Hat, Inc.
  *
  *
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -77,5 +77,20 @@ main(void)
 	assert(utils_strtonum("test", -1000, 1000, &ll) == -1);
 	assert(utils_strtonum("test", -1000, 1000, &ll) == -1);
 	assert(utils_strtonum("12a", -1000, 1000, &ll) == -1);
 	assert(utils_strtonum("12a", -1000, 1000, &ll) == -1);
 
 
+	assert(utils_parse_bool_str("on") == 1);
+	assert(utils_parse_bool_str("yes") == 1);
+	assert(utils_parse_bool_str("1") == 1);
+	assert(utils_parse_bool_str("ON") == 1);
+	assert(utils_parse_bool_str("YeS") == 1);
+
+	assert(utils_parse_bool_str("off") == 0);
+	assert(utils_parse_bool_str("no") == 0);
+	assert(utils_parse_bool_str("0") == 0);
+	assert(utils_parse_bool_str("oFf") == 0);
+
+	assert(utils_parse_bool_str("of") == -1);
+	assert(utils_parse_bool_str("noo") == -1);
+	assert(utils_parse_bool_str("01") == -1);
+
 	return (0);
 	return (0);
 }
 }