With the recent changes to lib/mbrtoc32.c and lib/btoc32.c, it is worth checking whether the two functions are still in sync. Fortunately, they are.
2026-09-18 Bruno Haible <[email protected]> btoc32 tests: Enhance tests. * tests/test-btoc32.c (main): Verify that btoc32 is consistent with mbrtoc32. * modules/btoc32-tests (Depends-on): Add mbszero, mbrtoc32. diff --git a/modules/btoc32-tests b/modules/btoc32-tests index edeccf3f05..182492c0f6 100644 --- a/modules/btoc32-tests +++ b/modules/btoc32-tests @@ -11,6 +11,8 @@ m4/codeset.m4 Depends-on: setlocale +mbszero +mbrtoc32 streq configure.ac: diff --git a/tests/test-btoc32.c b/tests/test-btoc32.c index a19f0896c5..ae367b7e6e 100644 --- a/tests/test-btoc32.c +++ b/tests/test-btoc32.c @@ -38,6 +38,21 @@ main (int argc, char *argv[]) ASSERT (btoc32 (EOF) == WEOF); + /* Verify that btoc32 is consistent with mbrtoc32. */ + for (int c = 0; c < 0x100; c++) + if (c != 0) + { + mbstate_t state; + mbszero (&state); + char s[1]; + s[0] = (unsigned char) c; + char32_t wc; + if (mbrtoc32 (&wc, s, 1, &state) <= 1) + ASSERT (btoc32 (c) == wc); + else + ASSERT (btoc32 (c) == WEOF); + } + #ifdef __ANDROID__ /* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the "C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
