aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/blogc-git-receiver/check_shell_command_parser.c29
-rw-r--r--tests/common/check_utils.c31
2 files changed, 31 insertions, 29 deletions
diff --git a/tests/blogc-git-receiver/check_shell_command_parser.c b/tests/blogc-git-receiver/check_shell_command_parser.c
index 9d0e282..a97df60 100644
--- a/tests/blogc-git-receiver/check_shell_command_parser.c
+++ b/tests/blogc-git-receiver/check_shell_command_parser.c
@@ -205,40 +205,11 @@ test_shell_command_parse(void **state)
}
-static void
-test_shell_quote(void **state)
-{
- char *t;
- t = bgr_shell_quote(NULL);
- assert_string_equal(t, "''");
- free(t);
- t = bgr_shell_quote("!bola");
- assert_string_equal(t, "''\\!'bola'");
- free(t);
- t = bgr_shell_quote("'bola");
- assert_string_equal(t, "''\\''bola'");
- free(t);
- t = bgr_shell_quote("bo!bola");
- assert_string_equal(t, "'bo'\\!'bola'");
- free(t);
- t = bgr_shell_quote("bo'bola");
- assert_string_equal(t, "'bo'\\''bola'");
- free(t);
- t = bgr_shell_quote("bola!");
- assert_string_equal(t, "'bola'\\!''");
- free(t);
- t = bgr_shell_quote("bola'");
- assert_string_equal(t, "'bola'\\'''");
- free(t);
-}
-
-
int
main(void)
{
const UnitTest tests[] = {
unit_test(test_shell_command_parse),
- unit_test(test_shell_quote),
};
return run_tests(tests);
}
diff --git a/tests/common/check_utils.c b/tests/common/check_utils.c
index f761cd8..955503b 100644
--- a/tests/common/check_utils.c
+++ b/tests/common/check_utils.c
@@ -943,6 +943,34 @@ test_trie_foreach(void **state)
}
+static void
+test_shell_quote(void **state)
+{
+ char *t;
+ t = bc_shell_quote(NULL);
+ assert_string_equal(t, "''");
+ free(t);
+ t = bc_shell_quote("!bola");
+ assert_string_equal(t, "''\\!'bola'");
+ free(t);
+ t = bc_shell_quote("'bola");
+ assert_string_equal(t, "''\\''bola'");
+ free(t);
+ t = bc_shell_quote("bo!bola");
+ assert_string_equal(t, "'bo'\\!'bola'");
+ free(t);
+ t = bc_shell_quote("bo'bola");
+ assert_string_equal(t, "'bo'\\''bola'");
+ free(t);
+ t = bc_shell_quote("bola!");
+ assert_string_equal(t, "'bola'\\!''");
+ free(t);
+ t = bc_shell_quote("bola'");
+ assert_string_equal(t, "'bola'\\'''");
+ free(t);
+}
+
+
int
main(void)
{
@@ -987,6 +1015,9 @@ main(void)
unit_test(test_trie_lookup),
unit_test(test_trie_size),
unit_test(test_trie_foreach),
+
+ // shell
+ unit_test(test_shell_quote),
};
return run_tests(tests);
}