git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Achu Luma <ach.lumap@gmail.com>, git@vger.kernel.org
Cc: gitster@pobox.com, chriscool@tuxfamily.org,
	christian.couder@gmail.com, l.s.r@web.de,
	phillip.wood@dunelm.org.uk, steadmon@google.com, me@ttaylorr.com
Subject: Re: [Outreachy][PATCH v4] Port helper/test-ctype.c to unit-tests/t-ctype.c
Date: Tue, 9 Jan 2024 10:35:11 +0000	[thread overview]
Message-ID: <33c81610-0958-49da-b702-ba8d96ecf1d3@gmail.com> (raw)
In-Reply-To: <20240105161413.10422-1-ach.lumap@gmail.com>

Hi Achu

On 05/01/2024 16:14, Achu Luma wrote:
> In the recent codebase update (8bf6fbd00d (Merge branch
> 'js/doc-unit-tests', 2023-12-09)), a new unit testing framework was
> merged, providing a standardized approach for testing C code. Prior to
> this update, some unit tests relied on the test helper mechanism,
> lacking a dedicated unit testing framework. It's more natural to perform
> these unit tests using the new unit test framework.
> 
> This commit migrates the unit tests for C character classification
> functions (isdigit(), isspace(), etc) from the legacy approach
> using the test-tool command `test-tool ctype` in t/helper/test-ctype.c
> to the new unit testing framework (t/unit-tests/test-lib.h).
> 
> The migration involves refactoring the tests to utilize the testing
> macros provided by the framework (TEST() and check_*()).
> 
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Helped-by: René Scharfe <l.s.r@web.de>
> Helped-by: Phillip Wood <phillip.wood123@gmail.com>
> Helped-by: Taylor Blau <me@ttaylorr.com>
> Signed-off-by: Achu Luma <ach.lumap@gmail.com>
> ---
>   The changes between version 3 and version 4 are the following:
> 
>   - Some duplication has been reduced using a new TEST_CHAR_CLASS() macro.
>   - A "0x"prefix has been added to avoid confusion between decimal and
>     hexadecimal codes printed by test_msg().
>   - The "Mentored-by:..." trailer has been restored.
>   - "works as expected" has been reduced to just "works" as suggested by Taylor.
>   - Some "Helped-by: ..." trailers have been added.
>   - Some whitespace fixes have been made.

Thanks for the re-roll, the changes look good, there is one issue that I 
spotted below

> -#define TEST_CLASS(t,s) {			\
> -	int i;					\
> -	for (i = 0; i < 256; i++) {		\
> -		if (is_in(s, i) != t(i))	\
> -			report_error(#t, i);	\
> -	}					\
> -	if (t(EOF))				\
> -		report_error(#t, EOF);		\
> -}

In the old version we test EOF in addition to each character between 0-255

> +/* Macro to test a character type */
> +#define TEST_CTYPE_FUNC(func, string) \
> +static void test_ctype_##func(void) { \
> +	for (int i = 0; i < 256; i++) { \
> +		if (!check_int(func(i), ==, is_in(string, i))) \
> +			test_msg("       i: 0x%02x", i); \
> +	} \
> +}

In the new version we only test the characters 0-255, not EOF. If there 
is a good reason for removing the EOF tests then it should be explained 
in the commit message. If not it would be good to add those tests back.

Best Wishes

Phillip

  parent reply	other threads:[~2024-01-09 10:35 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 23:15 [PATCH] Port helper/test-ctype.c to unit-tests/t-ctype.c Achu Luma
2023-12-26 18:45 ` Junio C Hamano
2023-12-27 10:57   ` Christian Couder
2023-12-27 11:57     ` René Scharfe
2023-12-27 14:40       ` Phillip Wood
2023-12-27 23:48       ` Junio C Hamano
2023-12-28 16:05         ` René Scharfe
2024-01-02 18:55   ` Taylor Blau
2023-12-30  0:09 ` [Outreachy][PATCH v2] " Achu Luma
2024-01-01 10:40   ` [Outreachy][PATCH v3] " Achu Luma
2024-01-01 16:41     ` René Scharfe
2024-01-02 16:35       ` Junio C Hamano
2024-01-05 16:14     ` [Outreachy][PATCH v4] " Achu Luma
2024-01-07 12:45       ` René Scharfe
2024-01-08 22:32         ` Junio C Hamano
2024-01-09 10:35       ` Phillip Wood [this message]
2024-01-09 17:12         ` Junio C Hamano
2024-01-12 10:27       ` [Outreachy][PATCH v5] " Achu Luma
2024-01-15 10:39         ` Phillip Wood
2024-01-16 15:38           ` Junio C Hamano
2024-01-16 19:27             ` René Scharfe
2024-01-16 19:45               ` Christian Couder
2024-01-16 19:52               ` Junio C Hamano
2024-01-17  5:37               ` Josh Steadmon

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=33c81610-0958-49da-b702-ba8d96ecf1d3@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=ach.lumap@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=me@ttaylorr.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=steadmon@google.com \
    /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).