tests: add test of function string_split_shell with an empty string

This commit is contained in:
Sébastien Helleu 2014-10-12 18:09:57 +02:00
parent 9249738582
commit 45a0bfe1b3

View File

@ -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 */