Re: [PATCH 1/2] u-string-list: add unit tests for string-list methods
On Mon, 26 Jan 2026 at 12:42, Junio C Hamano <gitster@pobox.com> wrote:
Show 46 quoted lines
>
> Amisha Chhajed <amishhhaaaa@gmail.com> writes:
>
> > Unit tests in u-string-list.c does not cover several methods
> > in string-list, this gap in coverage makes it difficult to
> > ensure no regressions are introduced in future changes.
> >
> > Add unit tests for the following methods to enhance coverage:
> > string_list_remove_empty_items()
> > unsorted_string_list_has_string()
> > unsorted_string_list_delete_item()
> > string_list_has_string()
> > string_list_insert()
> > string_list_sort()
> > string_list_remove()
> >
> > Signed-off-by: Amisha Chhajed <amishhhaaaa@gmail.com>
> > ---
> > t/unit-tests/u-string-list.c | 197 +++++++++++++++++++++++++++++++++++
> > 1 file changed, 197 insertions(+)
> >
> > diff --git a/t/unit-tests/u-string-list.c b/t/unit-tests/u-string-list.c
> > index a2457d7b1e..6b4b858330 100644
> > --- a/t/unit-tests/u-string-list.c
> > +++ b/t/unit-tests/u-string-list.c
> > @@ -243,6 +243,133 @@ void test_string_list__filter(void)
> > ...
> > +static void t_string_list_insert(struct string_list *expected_strings, ...)
> > +{
> > + struct string_list strings_to_insert = STRING_LIST_INIT_DUP;
> > + struct string_list list = STRING_LIST_INIT_DUP;
> > + va_list ap;
> > +
> > + va_start(ap, expected_strings);
> > + t_vcreate_string_list_dup(&strings_to_insert, 0, ap);
> > + va_end(ap);
> > +
> > + for (int i = 0; i < strings_to_insert.nr; i++) {
>
> As strings_to_insert.nr is of type size_t, even though int is plenty
> large enough in practice, the compiler will complain.
>
> > + string_list_insert(&list, strings_to_insert.items[i].string);
> > + }
>
> Also, lose the {} around a single statement block.Done, Thanks for the review.