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

Re: [GSoC][PATCH v2 3/4] t: move tests from reftable/record_test.c to the new unit test

From
Patrick Steinhardt <ps@pks.im>
Date
May 29, 2024, 09:30 UTC
Message-ID
<Zlb1m5cwhW_R5EzP@tanuki>
In-Reply-To
<20240529070341.4248-4-chandrapratap3519@gmail.com>

On Wed, May 29, 2024 at 12:25:11PM +0530, Chandra Pratap wrote: [snip]

Show 38 quoted lines
> diff --git a/t/unit-tests/t-reftable-basics.c b/t/unit-tests/t-reftable-basics.c
> index 55fcff12d9..b02ca02040 100644
> --- a/t/unit-tests/t-reftable-basics.c
> +++ b/t/unit-tests/t-reftable-basics.c
> @@ -99,13 +99,38 @@ static void test_parse_names_drop_empty(void)
>  
>  static void test_common_prefix(void)
>  {
> -	struct strbuf s1 = STRBUF_INIT;
> -	struct strbuf s2 = STRBUF_INIT;
> -	strbuf_addstr(&s1, "abcdef");
> -	strbuf_addstr(&s2, "abc");
> -	check_int(common_prefix_size(&s1, &s2), ==, 3);
> -	strbuf_release(&s1);
> -	strbuf_release(&s2);
> +	struct strbuf a = STRBUF_INIT;
> +	struct strbuf b = STRBUF_INIT;
> +	struct {
> +		const char *a, *b;
> +		int want;
> +	} cases[] = {
> +		{"abcdef", "abc", 3},
> +		{ "abc", "ab", 2 },
> +		{ "", "abc", 0 },
> +		{ "abc", "abd", 2 },
> +		{ "abc", "pqr", 0 },
> +	};
> +
> +	for (size_t i = 0; i < ARRAY_SIZE(cases); i++) {
> +		strbuf_addstr(&a, cases[i].a);
> +		strbuf_addstr(&b, cases[i].b);
> +		check_int(common_prefix_size(&a, &b), ==, cases[i].want);
> +		strbuf_reset(&a);
> +		strbuf_reset(&b);
> +	}
> +	strbuf_release(&a);
> +	strbuf_release(&b);
> +}

Oh, so this test was even duplicated. It may make sense to point out details like this in the commit message to prepare the reader. But that's probably not worth a reroll.

Patrick
Previous: Chandra PratapNext: Junio C Hamano
Message 5 of 18 in “t: port reftable/basics_test.c to the unit testing”
  1. Chandra PratapMay 29, 2024
  2. [GSoC][PATCH v2 1/4] t: move reftable/basics_test.c to the unit testing frameworkChandra Pratap, May 29, 2024
  3. [GSoC][PATCH v2 2/4] t: move tests from reftable/stack_test.c to the new unit testChandra Pratap, May 29, 2024
  4. [GSoC][PATCH v2 3/4] t: move tests from reftable/record_test.c to the new unit testChandra Pratap, May 29, 2024
  5. Patrick SteinhardtMay 29, 2024
  6. Junio C HamanoMay 29, 2024
  7. [GSoC][PATCH v2 4/4] t: add test for put_be16() and improve test-case for parse_names()Chandra Pratap, May 29, 2024
  8. Patrick SteinhardtMay 29, 2024
  9. Patrick SteinhardtMay 29, 2024
  10. [GSoC][PATCH v3 0/4] t: port reftable/basics_test.c to the unit testingChandra Pratap, May 29, 2024
  11. [GSoC][PATCH v3 1/5] t: move reftable/basics_test.c to the unit testing frameworkChandra Pratap, May 29, 2024
  12. [GSoC][PATCH v3 2/5] t: move tests from reftable/stack_test.c to the new unit testChandra Pratap, May 29, 2024
  13. [GSoC][PATCH v3 3/5] t: move tests from reftable/record_test.c to the new unit testChandra Pratap, May 29, 2024
  14. [GSoC][PATCH v3 4/5] t: add test for put_be16()Chandra Pratap, May 29, 2024
  15. [GSoC][PATCH v3 5/5] t: improve the test-case for parse_names()Chandra Pratap, May 29, 2024
  16. Patrick SteinhardtMay 30, 2024
  17. Christian CouderMay 30, 2024
  18. Junio C HamanoMay 30, 2024

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.