From da3273891c50ffabbfcc8c6e6c674f01cfc226b3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 14 Dec 2022 16:56:17 +0100 Subject: [PATCH] tests: add another pw_split_strv test To check if an empty string after a delimiter is counted. --- test/test-utils.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-utils.c b/test/test-utils.c index 9b7c520e2..84a2fcb4c 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -193,6 +193,8 @@ static void test__pw_split_strv(void) { const char *test1 = "a \n test string \n \r "; const char *del = "\n\r "; + const char *test2 = "a:"; + const char *del2 = ":"; int n_tokens; char **res; @@ -212,6 +214,13 @@ static void test__pw_split_strv(void) pwtest_str_eq(res[1], "test string \n \r "); pwtest_ptr_null(res[2]); pw_free_strv(res); + + res = pw_split_strv(test2, del2, 2, &n_tokens); + pwtest_ptr_notnull(res); + pwtest_int_eq(n_tokens, 1); + pwtest_str_eq(res[0], "a"); + pwtest_ptr_null(res[1]); + pw_free_strv(res); } PWTEST(utils_split)