From 45a0bfe1b30c56e237519ea8806ba13d08ac7187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 12 Oct 2014 18:09:57 +0200 Subject: [PATCH] tests: add test of function string_split_shell with an empty string --- tests/unit/core/test-string.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/unit/core/test-string.cpp b/tests/unit/core/test-string.cpp index 4dcde55b8..e80698f56 100644 --- a/tests/unit/core/test-string.cpp +++ b/tests/unit/core/test-string.cpp @@ -791,6 +791,15 @@ TEST(String, SplitShell) POINTERS_EQUAL(NULL, string_split_shell (NULL, NULL)); + /* test with an empty string */ + argc = -1; + argv = string_split_shell ("", &argc); + LONGS_EQUAL(0, argc); + CHECK(argv); + POINTERS_EQUAL(NULL, argv[0]); + string_free_split (argv); + + /* test with a real string (command + arguments) */ argv = string_split_shell ("/path/to/bin arg1 \"arg2 here\" 'arg3 here'", &argc); LONGS_EQUAL(4, argc); @@ -800,7 +809,6 @@ TEST(String, SplitShell) STRCMP_EQUAL("arg2 here", argv[2]); STRCMP_EQUAL("arg3 here", argv[3]); POINTERS_EQUAL(NULL, argv[4]); - string_free_split (argv); /* free split with NULL */