git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] u-string-list: add unit tests for string-list methods

From
Amisha Chhajed <amishhhaaaa@gmail.com>
Date
Jan 26, 2026, 18:57 UTC
Message-ID
<CAPvEtrcLrrRhOi2OCaQzD6xNSHbyv38cr5-WLRPg_HGW5UKzAg@mail.gmail.com>
In-Reply-To
<xmqqpl6wkftw.fsf@gitster.g>
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.
Previous: Junio C HamanoNext: Junio C Hamano
Message 16 of 24 in “Adding string_list_sort_u to replace combined calls of string_list_sort and string_list_remove_duplicates calls.”
  1. 0/2 Adding string_list_sort_u to replace combined calls of string_list_sort and string_list_remove_duplicates calls.Amisha Chhajed, Jan 22, 2026
  2. 1/2 Adding string_list_sort_u which sorts a list then deduplicates it.Amisha Chhajed, Jan 22, 2026
  3. Junio C HamanoJan 22, 2026
  4. Amisha ChhajedJan 25, 2026
  5. 2/2 Replacing calls of string_list_sort and string_list_remove_duplicates with the combined variant string_list_u.Amisha Chhajed, Jan 22, 2026
  6. Junio C HamanoJan 22, 2026
  7. Junio C HamanoJan 22, 2026
  8. 1/2 u-string-list: add unit tests for string-list methodsAmisha Chhajed, Jan 25, 2026
  9. 2/2 string-list: add string_list_sort_u() that mimics "sort -u"Amisha Chhajed, Jan 25, 2026
  10. 1/2 u-string-list: add unit tests for string-list methodsAmisha Chhajed, Jan 29, 2026
  11. 2/2 string-list: add string_list_sort_u() that mimics "sort -u"Amisha Chhajed, Jan 29, 2026
  12. Amisha ChhajedJan 29, 2026
  13. Kristoffer HaugsbakkJan 30, 2026
  14. Junio C HamanoJan 30, 2026
  15. Junio C HamanoJan 26, 2026
  16. Amisha ChhajedJan 26, 2026
  17. Junio C HamanoJan 26, 2026
  18. 1/2 u-string-list: add unit tests for string-list methodsAmisha Chhajed, Jan 25, 2026
  19. 2/2 string-list: add string_list_sort_u() that mimics "sort -u"Amisha Chhajed, Jan 25, 2026
  20. 1/2 u-string-list: add unit tests for string-list methodsAmisha Chhajed, Jan 26, 2026
  21. 2/2 string-list: add string_list_sort_u() that mimics "sort -u"Amisha Chhajed, Jan 26, 2026
  22. Junio C HamanoJan 26, 2026
  23. Amisha ChhajedJan 27, 2026
  24. Junio C HamanoJan 26, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.