git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Seyi Kuforiji <kuforiji98@gmail.com>
Cc: git@vger.kernel.org,  ps@pks.im,  phillip.wood@dunelm.org.uk
Subject: Re: [PATCH 1/2] t/unit-tests: convert trailer test to use clar
Date: Tue, 04 Mar 2025 09:59:12 -0800	[thread overview]
Message-ID: <xmqqzfi0pthr.fsf@gitster.g> (raw)
In-Reply-To: <20250304113323.10564-2-kuforiji98@gmail.com> (Seyi Kuforiji's message of "Tue, 4 Mar 2025 12:33:22 +0100")

Seyi Kuforiji <kuforiji98@gmail.com> writes:

> diff --git a/t/unit-tests/u-trailer.c b/t/unit-tests/u-trailer.c
> new file mode 100644
> index 0000000000..3d60ea1603
> --- /dev/null
> +++ b/t/unit-tests/u-trailer.c

It is a bit sad (not your fault) that this is not shown as a
rename+modification patch, as most of the logic seem to be straight
out of the original.

> +void test_trailer__no_newline_start(void)
> +{
> +	struct contents expected_contents[] = { 0 };
> +
> +	t_trailer_iterator("Fixes: x\n"
> +			   "Acked-by: x\n"
> +			   "Reviewed-by: x\n",
> +			   0,
> +			   expected_contents);
> +}
> +
> +void test_trailer__newline_start(void)
> +{
> +	struct contents expected_contents[] = {
> +		{
> +			.raw = "Fixes: x\n",
> +			.key = "Fixes",
> +			.val = "x",
> +		},
> +		{
> +			.raw = "Acked-by: x\n",
> +			.key = "Acked-by",
> +			.val = "x",
> +		},
> +		{
> +			.raw = "Reviewed-by: x\n",
> +			.key = "Reviewed-by",
> +			.val = "x",
> +		},
> +		{
> +			0
> +		},
> +	};
> +
> +	t_trailer_iterator("\n"
> +			   "Fixes: x\n"
> +			   "Acked-by: x\n"
> +			   "Reviewed-by: x\n",
> +			   3,
> +			   expected_contents);
> +}

This is inherited from the original, but the hardcoded "3" feels a
bit brittle.

Would ARRAY_SIZE(expected_contents)-1 always match the expected
number, I wonder?  Even if it is, improving it is totally outside
the scope of this topic.  I am just mentioning this since I will
forget if I don't ;-).

  reply	other threads:[~2025-03-04 17:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 11:33 [PATCH 0/2] t/unit-tests: convert unit-tests to use clar Seyi Kuforiji
2025-03-04 11:33 ` [PATCH 1/2] t/unit-tests: convert trailer test " Seyi Kuforiji
2025-03-04 17:59   ` Junio C Hamano [this message]
2025-03-04 11:33 ` [PATCH 2/2] t/unit-tests: convert urlmatch-normalization test to clar Seyi Kuforiji

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqzfi0pthr.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=kuforiji98@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=ps@pks.im \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).