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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 29, 2024 at 12:25:11PM +0530, Chandra Pratap wrote:
[snip]
> 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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux