diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-05-14 09:14:08 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-05-14 09:14:08 +0200 |
commit | 22c096638758a842a084db51e35508ac323890af (patch) | |
tree | 8924060c5373af42288f503bee5db418731319a9 /tests/unit | |
parent | af83fb55e10b3648656f540a5cb3ec826ea7440c (diff) | |
download | weechat-22c096638758a842a084db51e35508ac323890af.zip |
tests: add tests on function string_split_command()
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/core/test-string.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/unit/core/test-string.cpp b/tests/unit/core/test-string.cpp index 46314eb2b..0947e16b7 100644 --- a/tests/unit/core/test-string.cpp +++ b/tests/unit/core/test-string.cpp @@ -931,15 +931,33 @@ TEST(String, SplitCommand) { char **argv; + /* test with a NULL/empty string */ POINTERS_EQUAL(NULL, string_split_command (NULL, ';')); POINTERS_EQUAL(NULL, string_split_command ("", ';')); + + /* string with one command */ + argv = string_split_command ("abc", ';'); + CHECK(argv); + STRCMP_EQUAL("abc", argv[0]); + POINTERS_EQUAL(NULL, argv[1]); + string_free_split_command (argv); + + /* string with 3 commands */ argv = string_split_command ("abc;de;fghi", ';'); CHECK(argv); STRCMP_EQUAL("abc", argv[0]); STRCMP_EQUAL("de", argv[1]); STRCMP_EQUAL("fghi", argv[2]); POINTERS_EQUAL(NULL, argv[3]); + string_free_split_command (argv); + /* string with 3 commands (containing spaces) */ + argv = string_split_command (" abc ; de ; fghi ", ';'); + CHECK(argv); + STRCMP_EQUAL("abc ", argv[0]); + STRCMP_EQUAL("de ", argv[1]); + STRCMP_EQUAL("fghi ", argv[2]); + POINTERS_EQUAL(NULL, argv[3]); string_free_split_command (argv); /* separator other than ';' */ @@ -949,7 +967,6 @@ TEST(String, SplitCommand) STRCMP_EQUAL("de", argv[1]); STRCMP_EQUAL("fghi", argv[2]); POINTERS_EQUAL(NULL, argv[3]); - string_free_split_command (argv); /* free split with NULL */ |