diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-01-23 10:35:07 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-01-23 10:35:07 +0100 |
commit | 50817054f9a198c51056c71181529bbdaa095898 (patch) | |
tree | 101e4e02051687eb1c9d9994c502cdd6cdecc999 /tests/unit | |
parent | d6af8c312f1d5bdeb8f8642a79205ab87c4b56ed (diff) | |
download | weechat-50817054f9a198c51056c71181529bbdaa095898.zip |
tests: add tests on string_split() with keep_eol set to 2
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/core/test-string.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/unit/core/test-string.cpp b/tests/unit/core/test-string.cpp index 724de17ce..67e578d45 100644 --- a/tests/unit/core/test-string.cpp +++ b/tests/unit/core/test-string.cpp @@ -812,7 +812,7 @@ TEST(String, Split) POINTERS_EQUAL(NULL, argv[2]); string_free_split (argv); - /* keep eol */ + /* keep eol == 1 */ argv = string_split (" abc de fghi ", " ", 1, 0, &argc); LONGS_EQUAL(3, argc); CHECK(argv); @@ -822,7 +822,7 @@ TEST(String, Split) POINTERS_EQUAL(NULL, argv[3]); string_free_split (argv); - /* keep eol and max 2 items */ + /* keep eol == 1 and max 2 items */ argv = string_split (" abc de fghi ", " ", 1, 2, &argc); LONGS_EQUAL(2, argc); CHECK(argv); @@ -830,6 +830,25 @@ TEST(String, Split) STRCMP_EQUAL("de fghi", argv[1]); POINTERS_EQUAL(NULL, argv[2]); string_free_split (argv); + + /* keep eol == 2 */ + argv = string_split (" abc de fghi ", " ", 2, 0, &argc); + LONGS_EQUAL(3, argc); + CHECK(argv); + STRCMP_EQUAL("abc de fghi ", argv[0]); + STRCMP_EQUAL("de fghi ", argv[1]); + STRCMP_EQUAL("fghi ", argv[2]); + POINTERS_EQUAL(NULL, argv[3]); + string_free_split (argv); + + /* keep eol == 2 and max 2 items */ + argv = string_split (" abc de fghi ", " ", 2, 2, &argc); + LONGS_EQUAL(2, argc); + CHECK(argv); + STRCMP_EQUAL("abc de fghi ", argv[0]); + STRCMP_EQUAL("de fghi ", argv[1]); + POINTERS_EQUAL(NULL, argv[2]); + string_free_split (argv); } /* |