Browse Source

libdpkg: Add test cases for str_is_set() and str_is_unset()

Guillem Jover 12 years ago
parent
commit
5a20d9d36d
1 changed files with 16 additions and 1 deletions
  1. 16 1
      lib/dpkg/test/t-string.c

+ 16 - 1
lib/dpkg/test/t-string.c

@@ -27,6 +27,20 @@
 #include <stdlib.h>
 #include <string.h>
 
+static void
+test_str_is_set(void)
+{
+	/* Test if strings are unset. */
+	test_pass(str_is_unset(NULL));
+	test_pass(str_is_unset(""));
+	test_fail(str_is_unset("aaa"));
+
+	/* Test if strings are set. */
+	test_fail(str_is_set(NULL));
+	test_fail(str_is_set(""));
+	test_pass(str_is_set("ccc"));
+}
+
 static void
 test_str_match_end(void)
 {
@@ -137,8 +151,9 @@ test_str_strip_quotes(void)
 static void
 test(void)
 {
-	test_plan(23);
+	test_plan(29);
 
+	test_str_is_set();
 	test_str_match_end();
 	test_str_escape_fmt();
 	test_str_quote_meta();