Re: [PATCH 1/2] t/unit-tests: convert trailer test to use clar
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 4, 2025, 17:59 UTC
- Message-ID
- <xmqqzfi0pthr.fsf@gitster.g>
- In-Reply-To
- <20250304113323.10564-2-kuforiji98@gmail.com>
Seyi Kuforiji <kuforiji98@gmail.com> writes:
Show 5 quoted lines
> 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.
Show 41 quoted lines
> +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 ;-).