Re: [PATCH v5 9/9] t/unit-tests: convert ctype tests to use clar
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Aug 20, 2024, 12:59 UTC
- Message-ID
- <ZsSTNV3EeTJQ3Ywn@tanuki>
- In-Reply-To
- <4aa6f557-1dfc-4aaa-b6db-e47013568ecc@gmail.com>
On Fri, Aug 16, 2024 at 02:38:30PM +0100, Phillip Wood wrote:
Show 22 quoted lines
> 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?
>
> ThanksI'll introduce a new function `cl_failf()` that allows us to print information like this.
Patrick