From: Christian Couder <christian.couder@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Achu Luma <ach.lumap@gmail.com>,
git@vger.kernel.org, Christian Couder <chriscool@tuxfamily.org>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Josh Steadmon <steadmon@google.com>
Subject: Re: [PATCH] Port helper/test-ctype.c to unit-tests/t-ctype.c
Date: Wed, 27 Dec 2023 11:57:23 +0100 [thread overview]
Message-ID: <CAP8UFD1vC6=7ESx1w7S9Q9P0Bsc+c03wgHToNBaP+ivvm9BKBg@mail.gmail.com> (raw)
In-Reply-To: <xmqqsf3ohkew.fsf@gitster.g>
On Tue, Dec 26, 2023 at 7:46 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Achu Luma <ach.lumap@gmail.com> writes:
> > +/* Macro to test a character type */
> > +#define TEST_CTYPE_FUNC(func, string) \
> > +static void test_ctype_##func(void) \
> > +{ \
> > + int i; \
> > + for (i = 0; i < 256; i++) \
> > + check_int(func(i), ==, is_in(string, i)); \
> > +}
>
> Now, we let check_int() to do the checking for each and every byte
> value for the class. check_int() uses different reporting and shows
> the problematic value in a way that is more verbose and at the same
> time is a less specific and harder to understand:
>
> test_msg(" left: %"PRIdMAX, a);
> test_msg(" right: %"PRIdMAX, b);
>
> But that is probably the price to pay to use a more generic
> framework, I guess.
I have added Phillip and Josh in Cc: as they might have ideas about this.
Also it might not be a big issue here, but when the new unit test
framework was proposed, I commented on the fact that "left" and
"right" were perhaps a bit less explicit than "actual" and "expected".
> > +int cmd_main(int argc, const char **argv) {
> > + /* Run all character type tests */
> > + TEST(test_ctype_isspace(), "isspace() works as we expect");
> > + TEST(test_ctype_isdigit(), "isdigit() works as we expect");
> > + TEST(test_ctype_isalpha(), "isalpha() works as we expect");
> > + TEST(test_ctype_isalnum(), "isalnum() works as we expect");
> > + TEST(test_ctype_is_glob_special(), "is_glob_special() works as we expect");
> > + TEST(test_ctype_is_regex_special(), "is_regex_special() works as we expect");
> > + TEST(test_ctype_is_pathspec_magic(), "is_pathspec_magic() works as we expect");
> > + TEST(test_ctype_isascii(), "isascii() works as we expect");
> > + TEST(test_ctype_islower(), "islower() works as we expect");
> > + TEST(test_ctype_isupper(), "isupper() works as we expect");
> > + TEST(test_ctype_iscntrl(), "iscntrl() works as we expect");
> > + TEST(test_ctype_ispunct(), "ispunct() works as we expect");
> > + TEST(test_ctype_isxdigit(), "isxdigit() works as we expect");
> > + TEST(test_ctype_isprint(), "isprint() works as we expect");
> > +
> > + return test_done();
> > +}
>
> As a practice to use the unit-tests framework, the patch looks OK.
> helper/test-ctype.c indeed is an oddball that runs once and checks
> everything it wants to check, for which the unit tests framework is
> much more suited.
Yeah, I agree.
> Let's see how others react and then queue.
>
> Thanks.
next prev parent reply other threads:[~2023-12-27 10:57 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 [this message]
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
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='CAP8UFD1vC6=7ESx1w7S9Q9P0Bsc+c03wgHToNBaP+ivvm9BKBg@mail.gmail.com' \
--to=christian.couder@gmail.com \
--cc=ach.lumap@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).