Patrick Steinhardt <ps@xxxxxx> writes: > Convert the ctype tests to use the new clar unit testing framework. > > Signed-off-by: Patrick Steinhardt <ps@xxxxxx> > --- > Makefile | 2 +- > t/unit-tests/{t-ctype.c => ctype.c} | 71 +++++++++++++++++++++++------ > 2 files changed, 59 insertions(+), 14 deletions(-) > rename t/unit-tests/{t-ctype.c => ctype.c} (71%) In 'next' we use the if_test stuff to simplify the ctype unit tests. This gives a good example to illustrate the strengths and weakness of these approaches. I resolved the conflict in 'seen' with this topic in favor of clar tests so that it becomes easier to compare. > #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)); \ > + cl_assert(!class(EOF)); \ > } while (0)