Subject: Re: [PATCH 2/5] u-string-list: move "test_split" into "u-string-list.c"

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 23 Apr 2025 13:52:58 +0200

On Tue, Apr 22, 2025 at 10:54:55PM +0800, shejialuo wrote:
> diff --git a/t/unit-tests/u-string-list.c b/t/unit-tests/u-string-list.c
> new file mode 100644
> index 0000000000..0c148684ea
> --- /dev/null
> +++ b/t/unit-tests/u-string-list.c
> @@ -0,0 +1,86 @@
> +static void t_string_list_split(const char *data, int delim, int maxsplit,
> +				struct string_list *expected_strings)
> +{
> +	struct string_list list = STRING_LIST_INIT_DUP;
> +	int len;
> +
> +	len = string_list_split(&list, data, delim, maxsplit);
> +	cl_assert_equal_i(len, expected_strings->nr);
> +	t_check_string_list(&list, expected_strings);
> +
> +	t_string_list_clear(&list, 0);
> +}
> +
> +void test_string_list__split(void)
> +{
> +	struct string_list expected_strings = STRING_LIST_INIT_DUP;
> +
> +	t_create_string_list_dup(&expected_strings, 0, "foo", "bar", "baz", NULL);
> +	t_string_list_split("foo:bar:baz", ':', -1, &expected_strings);

Could we adapt `t_string_list_split()` so that it accepts the expected
strings as varargs? If so we could simplify the logic in this function
here.

Patrick