Subject: Re: [PATCH v5 9/9] t/unit-tests: convert ctype tests to use clar

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 20 Aug 2024 14:59:33 +0200

On Fri, Aug 16, 2024 at 02:38:30PM +0100, Phillip Wood wrote:
> Hi Patrick
> 
> On 16/08/2024 08:05, Patrick Steinhardt wrote:
> >   #define TEST_CHAR_CLASS(class, string) do { \
> >   	size_t len = ARRAY_SIZE(string) - 1 + \
> >   		BUILD_ASSERT_OR_ZERO(ARRAY_SIZE(string) > 0) + \
> >   		BUILD_ASSERT_OR_ZERO(sizeof(string[0]) == sizeof(char)); \
> > -	int skip = test__run_begin(); \
> > -	if (!skip) { \
> > -		for (int i = 0; i < 256; i++) { \
> > -			if (!check_int(class(i), ==, !!memchr(string, i, len)))\
> > -				test_msg("      i: 0x%02x", i); \
> > -		} \
> > -		check(!class(EOF)); \
> > -	} \
> > -	test__run_end(!skip, TEST_LOCATION(), #class " works"); \
> > +	for (int i = 0; i < 256; i++) \
> > +		cl_assert_equal_i(class(i), !!memchr(string, i, len)); \
> 
> If this fails how are we supposed to know which character it was checking?
> 
> Thanks

I'll introduce a new function `cl_failf()` that allows us to print
information like this.

Patrick