And likewise for the c-*z*printf modules:
2024-06-25 Bruno Haible <br...@clisp.org> c-vazsprintf-gnu: Add tests. * tests/test-vazsprintf-gnu.h: New file, extracted from tests/test-vazsprintf-gnu.c. * tests/test-vazsprintf-gnu.c: Include test-vazsprintf-gnu.h. (test_function): Moved out to tests/test-vazsprintf-gnu.h. * modules/vazsprintf-gnu-tests (Files): Add tests/test-vazsprintf-gnu.h. * tests/test-c-vazsprintf-gnu.c: New file. * tests/test-c-vazsprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-vazsprintf-gnu-tests: New file. c-vazsprintf-gnu: New module. * modules/c-vazsprintf-gnu: New file. 2024-06-25 Bruno Haible <br...@clisp.org> c-zsnprintf-gnu: Add tests. * tests/test-c-zsnprintf-gnu.c: New file. * tests/test-c-zsnprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-zsnprintf-gnu-tests: New file. c-zsnprintf-gnu: New module. * modules/c-zsnprintf-gnu: New file. 2024-06-25 Bruno Haible <br...@clisp.org> c-vzsnprintf-gnu: Add tests. * tests/test-c-vzsnprintf-gnu.c: New file, based on tests/test-vzsnprintf-gnu.c. * tests/test-c-vzsnprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-vzsnprintf-gnu-tests: New file. c-vzsnprintf-gnu: New module. * modules/c-vzsnprintf-gnu: New file.
>From f04e21fafb6211ff05d9e792ba3e79dd857c97bc Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:03:35 +0200 Subject: [PATCH 1/6] c-vzsnprintf-gnu: New module. * modules/c-vzsnprintf-gnu: New file. --- ChangeLog | 5 +++++ modules/c-vzsnprintf-gnu | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/c-vzsnprintf-gnu diff --git a/ChangeLog b/ChangeLog index 12be34ac2b..beab2cc12a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-06-25 Bruno Haible <br...@clisp.org> + + c-vzsnprintf-gnu: New module. + * modules/c-vzsnprintf-gnu: New file. + 2024-06-25 Bruno Haible <br...@clisp.org> c-vasnprintf: Add tests. diff --git a/modules/c-vzsnprintf-gnu b/modules/c-vzsnprintf-gnu new file mode 100644 index 0000000000..9a02c1d847 --- /dev/null +++ b/modules/c-vzsnprintf-gnu @@ -0,0 +1,23 @@ +Description: +c_vzsnprintf() function +with POSIX compliant and GNU compatible format string interpretation + +Files: + +Depends-on: +c-vzsnprintf +mixin/printf-gnu + +configure.ac: +gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS + +Makefile.am: + +Include: +"c-vsnprintf.h" + +License: +LGPLv2+ + +Maintainer: +all -- 2.34.1
>From 6888e9e333bf103431e2c0903e0b4490849b886d Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:04:02 +0200 Subject: [PATCH 2/6] c-vzsnprintf-gnu: Add tests. * tests/test-c-vzsnprintf-gnu.c: New file, based on tests/test-vzsnprintf-gnu.c. * tests/test-c-vzsnprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-vzsnprintf-gnu-tests: New file. --- ChangeLog | 7 +++++ modules/c-vzsnprintf-gnu-tests | 19 ++++++++++++ tests/test-c-vzsnprintf-gnu.c | 53 ++++++++++++++++++++++++++++++++++ tests/test-c-vzsnprintf-gnu.sh | 15 ++++++++++ 4 files changed, 94 insertions(+) create mode 100644 modules/c-vzsnprintf-gnu-tests create mode 100644 tests/test-c-vzsnprintf-gnu.c create mode 100755 tests/test-c-vzsnprintf-gnu.sh diff --git a/ChangeLog b/ChangeLog index beab2cc12a..e23e904e12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2024-06-25 Bruno Haible <br...@clisp.org> + c-vzsnprintf-gnu: Add tests. + * tests/test-c-vzsnprintf-gnu.c: New file, based on + tests/test-vzsnprintf-gnu.c. + * tests/test-c-vzsnprintf-gnu.sh: New file, based on + tests/test-c-snprintf.sh. + * modules/c-vzsnprintf-gnu-tests: New file. + c-vzsnprintf-gnu: New module. * modules/c-vzsnprintf-gnu: New file. diff --git a/modules/c-vzsnprintf-gnu-tests b/modules/c-vzsnprintf-gnu-tests new file mode 100644 index 0000000000..044c5f25ec --- /dev/null +++ b/modules/c-vzsnprintf-gnu-tests @@ -0,0 +1,19 @@ +Files: +tests/test-c-vzsnprintf-gnu.c +tests/test-zsnprintf-gnu.h +tests/test-c-vzsnprintf-gnu.sh +tests/macros.h +m4/locale-fr.m4 +m4/codeset.m4 + +Depends-on: +setlocale + +configure.ac: +gt_LOCALE_FR + +Makefile.am: +TESTS += test-c-vzsnprintf-gnu.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' +check_PROGRAMS += test-c-vzsnprintf-gnu +test_c_vzsnprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB) diff --git a/tests/test-c-vzsnprintf-gnu.c b/tests/test-c-vzsnprintf-gnu.c new file mode 100644 index 0000000000..4facc1f9c3 --- /dev/null +++ b/tests/test-c-vzsnprintf-gnu.c @@ -0,0 +1,53 @@ +/* Test of POSIX and GNU compatible c_vzsnprintf() function. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2024. */ + +#include <config.h> + +#include "c-vsnprintf.h" + +#include <locale.h> +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +#include "test-zsnprintf-gnu.h" + +static ptrdiff_t +my_c_zsnprintf (char *str, size_t size, const char *format, ...) +{ + va_list args; + ptrdiff_t ret; + + va_start (args, format); + ret = c_vzsnprintf (str, size, format, args); + va_end (args); + return ret; +} + +int +main (int argc, char *argv[]) +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + test_function (my_c_zsnprintf); + + return test_exit_status; +} diff --git a/tests/test-c-vzsnprintf-gnu.sh b/tests/test-c-vzsnprintf-gnu.sh new file mode 100755 index 0000000000..9d416a13ef --- /dev/null +++ b/tests/test-c-vzsnprintf-gnu.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-c-vzsnprintf-gnu${EXEEXT} 1 -- 2.34.1
>From ce74a5a244c361daa67ed9c50c44e582fc287d25 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:04:26 +0200 Subject: [PATCH 3/6] c-zsnprintf-gnu: New module. * modules/c-zsnprintf-gnu: New file. --- ChangeLog | 5 +++++ modules/c-zsnprintf-gnu | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/c-zsnprintf-gnu diff --git a/ChangeLog b/ChangeLog index e23e904e12..e096792f7b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-06-25 Bruno Haible <br...@clisp.org> + + c-zsnprintf-gnu: New module. + * modules/c-zsnprintf-gnu: New file. + 2024-06-25 Bruno Haible <br...@clisp.org> c-vzsnprintf-gnu: Add tests. diff --git a/modules/c-zsnprintf-gnu b/modules/c-zsnprintf-gnu new file mode 100644 index 0000000000..1955098d4a --- /dev/null +++ b/modules/c-zsnprintf-gnu @@ -0,0 +1,23 @@ +Description: +c_zsnprintf() function +with POSIX compliant and GNU compatible format string interpretation + +Files: + +Depends-on: +c-zsnprintf +mixin/printf-gnu + +configure.ac: +gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS + +Makefile.am: + +Include: +"c-snprintf.h" + +License: +LGPLv2+ + +Maintainer: +all -- 2.34.1
>From 0e195ef54da1e84ff2de6ec1091a233b9fff472c Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:04:43 +0200 Subject: [PATCH 4/6] c-zsnprintf-gnu: Add tests. * tests/test-c-zsnprintf-gnu.c: New file. * tests/test-c-zsnprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-zsnprintf-gnu-tests: New file. --- ChangeLog | 6 +++++ modules/c-zsnprintf-gnu-tests | 19 ++++++++++++++++ tests/test-c-zsnprintf-gnu.c | 41 +++++++++++++++++++++++++++++++++++ tests/test-c-zsnprintf-gnu.sh | 15 +++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 modules/c-zsnprintf-gnu-tests create mode 100644 tests/test-c-zsnprintf-gnu.c create mode 100755 tests/test-c-zsnprintf-gnu.sh diff --git a/ChangeLog b/ChangeLog index e096792f7b..d5ae16391d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2024-06-25 Bruno Haible <br...@clisp.org> + c-zsnprintf-gnu: Add tests. + * tests/test-c-zsnprintf-gnu.c: New file. + * tests/test-c-zsnprintf-gnu.sh: New file, based on + tests/test-c-snprintf.sh. + * modules/c-zsnprintf-gnu-tests: New file. + c-zsnprintf-gnu: New module. * modules/c-zsnprintf-gnu: New file. diff --git a/modules/c-zsnprintf-gnu-tests b/modules/c-zsnprintf-gnu-tests new file mode 100644 index 0000000000..6ae7df356d --- /dev/null +++ b/modules/c-zsnprintf-gnu-tests @@ -0,0 +1,19 @@ +Files: +tests/test-c-zsnprintf-gnu.c +tests/test-zsnprintf-gnu.h +tests/test-c-zsnprintf-gnu.sh +tests/macros.h +m4/locale-fr.m4 +m4/codeset.m4 + +Depends-on: +setlocale + +configure.ac: +gt_LOCALE_FR + +Makefile.am: +TESTS += test-c-zsnprintf-gnu.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' +check_PROGRAMS += test-c-zsnprintf-gnu +test_c_zsnprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB) diff --git a/tests/test-c-zsnprintf-gnu.c b/tests/test-c-zsnprintf-gnu.c new file mode 100644 index 0000000000..016c78247a --- /dev/null +++ b/tests/test-c-zsnprintf-gnu.c @@ -0,0 +1,41 @@ +/* Test of POSIX and GNU compatible c_zsnprintf() function. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2024. */ + +#include <config.h> + +#include "c-snprintf.h" + +#include <locale.h> +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +#include "test-zsnprintf-gnu.h" + +int +main (int argc, char *argv[]) +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + test_function (c_zsnprintf); + + return test_exit_status; +} diff --git a/tests/test-c-zsnprintf-gnu.sh b/tests/test-c-zsnprintf-gnu.sh new file mode 100755 index 0000000000..3edb34ebee --- /dev/null +++ b/tests/test-c-zsnprintf-gnu.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-c-zsnprintf-gnu${EXEEXT} 1 -- 2.34.1
>From 7a0bd0fbd7185783c7f93811de345b6abaa0097b Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:04:58 +0200 Subject: [PATCH 5/6] c-vazsprintf-gnu: New module. * modules/c-vazsprintf-gnu: New file. --- ChangeLog | 5 +++++ modules/c-vazsprintf-gnu | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 modules/c-vazsprintf-gnu diff --git a/ChangeLog b/ChangeLog index d5ae16391d..1fdcd9b45c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-06-25 Bruno Haible <br...@clisp.org> + + c-vazsprintf-gnu: New module. + * modules/c-vazsprintf-gnu: New file. + 2024-06-25 Bruno Haible <br...@clisp.org> c-zsnprintf-gnu: Add tests. diff --git a/modules/c-vazsprintf-gnu b/modules/c-vazsprintf-gnu new file mode 100644 index 0000000000..46690f4ddb --- /dev/null +++ b/modules/c-vazsprintf-gnu @@ -0,0 +1,23 @@ +Description: +c_azsprintf() and c_vazsprintf() functions +with POSIX compliant and GNU compatible format string interpretation + +Files: + +Depends-on: +c-vazsprintf +mixin/printf-gnu + +configure.ac: +gl_PREREQ_VASNPRINTF_WITH_GNU_EXTRAS + +Makefile.am: + +Include: +"c-vasprintf.h" + +License: +LGPLv2+ + +Maintainer: +all -- 2.34.1
From e7c993deb424cf29a3b87ab5fe3ad00350012981 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Wed, 26 Jun 2024 01:05:05 +0200 Subject: [PATCH 6/6] c-vazsprintf-gnu: Add tests. * tests/test-vazsprintf-gnu.h: New file, extracted from tests/test-vazsprintf-gnu.c. * tests/test-vazsprintf-gnu.c: Include test-vazsprintf-gnu.h. (test_function): Moved out to tests/test-vazsprintf-gnu.h. * modules/vazsprintf-gnu-tests (Files): Add tests/test-vazsprintf-gnu.h. * tests/test-c-vazsprintf-gnu.c: New file. * tests/test-c-vazsprintf-gnu.sh: New file, based on tests/test-c-snprintf.sh. * modules/c-vazsprintf-gnu-tests: New file. --- ChangeLog | 11 ++++++ modules/c-vazsprintf-gnu-tests | 19 ++++++++++ modules/vazsprintf-gnu-tests | 1 + tests/test-c-vazsprintf-gnu.c | 66 ++++++++++++++++++++++++++++++++++ tests/test-c-vazsprintf-gnu.sh | 15 ++++++++ tests/test-vazsprintf-gnu.c | 19 +--------- tests/test-vazsprintf-gnu.h | 34 ++++++++++++++++++ 7 files changed, 147 insertions(+), 18 deletions(-) create mode 100644 modules/c-vazsprintf-gnu-tests create mode 100644 tests/test-c-vazsprintf-gnu.c create mode 100755 tests/test-c-vazsprintf-gnu.sh create mode 100644 tests/test-vazsprintf-gnu.h diff --git a/ChangeLog b/ChangeLog index 1fdcd9b45c..359250daf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2024-06-25 Bruno Haible <br...@clisp.org> + c-vazsprintf-gnu: Add tests. + * tests/test-vazsprintf-gnu.h: New file, extracted from + tests/test-vazsprintf-gnu.c. + * tests/test-vazsprintf-gnu.c: Include test-vazsprintf-gnu.h. + (test_function): Moved out to tests/test-vazsprintf-gnu.h. + * modules/vazsprintf-gnu-tests (Files): Add tests/test-vazsprintf-gnu.h. + * tests/test-c-vazsprintf-gnu.c: New file. + * tests/test-c-vazsprintf-gnu.sh: New file, based on + tests/test-c-snprintf.sh. + * modules/c-vazsprintf-gnu-tests: New file. + c-vazsprintf-gnu: New module. * modules/c-vazsprintf-gnu: New file. diff --git a/modules/c-vazsprintf-gnu-tests b/modules/c-vazsprintf-gnu-tests new file mode 100644 index 0000000000..a7c5762b9c --- /dev/null +++ b/modules/c-vazsprintf-gnu-tests @@ -0,0 +1,19 @@ +Files: +tests/test-c-vazsprintf-gnu.c +tests/test-vazsprintf-gnu.h +tests/test-c-vazsprintf-gnu.sh +tests/macros.h +m4/locale-fr.m4 +m4/codeset.m4 + +Depends-on: +setlocale + +configure.ac: +gt_LOCALE_FR + +Makefile.am: +TESTS += test-c-vazsprintf-gnu.sh +TESTS_ENVIRONMENT += LOCALE_FR='@LOCALE_FR@' +check_PROGRAMS += test-c-vazsprintf-gnu +test_c_vazsprintf_gnu_LDADD = $(LDADD) $(SETLOCALE_LIB) diff --git a/modules/vazsprintf-gnu-tests b/modules/vazsprintf-gnu-tests index 33cb15cd56..80de638ce8 100644 --- a/modules/vazsprintf-gnu-tests +++ b/modules/vazsprintf-gnu-tests @@ -1,5 +1,6 @@ Files: tests/test-vazsprintf-gnu.c +tests/test-vazsprintf-gnu.h tests/macros.h Depends-on: diff --git a/tests/test-c-vazsprintf-gnu.c b/tests/test-c-vazsprintf-gnu.c new file mode 100644 index 0000000000..0db9948d06 --- /dev/null +++ b/tests/test-c-vazsprintf-gnu.c @@ -0,0 +1,66 @@ +/* Test of POSIX and GNU compatible c_vazsprintf() and c_azsprintf() functions. + Copyright (C) 2011-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2024. */ + +#include <config.h> + +#include "c-vasprintf.h" + +#include <locale.h> +#include <stdio.h> +#include <string.h> + +#include "macros.h" + +#include "test-vazsprintf-gnu.h" + +static ptrdiff_t +my_c_azsprintf (char **result, const char *format, ...) +{ + va_list args; + ptrdiff_t ret; + + va_start (args, format); + ret = c_vazsprintf (result, format, args); + va_end (args); + return ret; +} + +static void +test_c_vazsprintf () +{ + test_function (my_c_azsprintf); +} + +static void +test_c_azsprintf () +{ + test_function (c_azsprintf); +} + +int +main (int argc, char *argv[]) +{ + /* configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + test_c_vazsprintf (); + test_c_azsprintf (); + + return test_exit_status; +} diff --git a/tests/test-c-vazsprintf-gnu.sh b/tests/test-c-vazsprintf-gnu.sh new file mode 100755 index 0000000000..1410b4e51e --- /dev/null +++ b/tests/test-c-vazsprintf-gnu.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Test in an ISO-8859-1 or ISO-8859-15 locale. +: "${LOCALE_FR=fr_FR}" +if test $LOCALE_FR = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no traditional french locale is installed" + else + echo "Skipping test: no traditional french locale is supported" + fi + exit 77 +fi + +LC_ALL=$LOCALE_FR \ +${CHECKER} ./test-c-vazsprintf-gnu${EXEEXT} 1 diff --git a/tests/test-vazsprintf-gnu.c b/tests/test-vazsprintf-gnu.c index cd31b378ce..f0c015d1fb 100644 --- a/tests/test-vazsprintf-gnu.c +++ b/tests/test-vazsprintf-gnu.c @@ -31,24 +31,7 @@ #include "macros.h" -static void -test_function (ptrdiff_t (*my_azsprintf) (char **, const char *, ...)) -{ - char result[5000]; - - /* Test the support of the 'B' conversion specifier for binary output of - integers. */ - - { /* This test would fail on all platforms other than glibc ≥ 2.35. */ - char *result; - ptrdiff_t retval = - my_azsprintf (&result, "%#B %d", 12345, 33, 44, 55); - ASSERT (result != NULL); - ASSERT (strcmp (result, "0B11000000111001 33") == 0); - ASSERT (retval == strlen (result)); - free (result); - } -} +#include "test-vazsprintf-gnu.h" static ptrdiff_t my_azsprintf (char **result, const char *format, ...) diff --git a/tests/test-vazsprintf-gnu.h b/tests/test-vazsprintf-gnu.h new file mode 100644 index 0000000000..0aba9faa6a --- /dev/null +++ b/tests/test-vazsprintf-gnu.h @@ -0,0 +1,34 @@ +/* Test of POSIX and GNU compatible vazsprintf() and azsprintf() functions. + Copyright (C) 2007-2024 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +/* Written by Bruno Haible <br...@clisp.org>, 2024. */ + +static void +test_function (ptrdiff_t (*my_azsprintf) (char **, const char *, ...)) +{ + /* Test the support of the 'B' conversion specifier for binary output of + integers. */ + + { /* This test would fail on all platforms other than glibc ≥ 2.35. */ + char *result; + ptrdiff_t retval = + my_azsprintf (&result, "%#B %d", 12345, 33, 44, 55); + ASSERT (result != NULL); + ASSERT (strcmp (result, "0B11000000111001 33") == 0); + ASSERT (retval == strlen (result)); + free (result); + } +} -- 2.34.1