From 50817054f9a198c51056c71181529bbdaa095898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 23 Jan 2016 10:35:07 +0100 Subject: tests: add tests on string_split() with keep_eol set to 2 --- tests/unit/core/test-string.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tests/unit') 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); } /* -- cgit v1.2.3