From: Bruno Haible Date: Thu, 8 Feb 2024 00:24:12 +0000 (+0100) Subject: c-nstrftime: Add tests. X-Git-Tag: v1.0~451 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e9ae614c441e32027f5a0280f091ddc0c702a3ca;p=gnulib.git c-nstrftime: Add tests. * tests/test-c-nstrftime.c: New file, based on tests/test-nstrftime.c. * tests/test-c-nstrftime-1.sh: New file, based on tests/test-nstrftime-1.sh. * tests/test-c-nstrftime-2.sh: New file, based on tests/test-nstrftime-2.sh. * modules/c-nstrftime-tests: New file. --- diff --git a/ChangeLog b/ChangeLog index 0d9b82b1e9..53f6cb1765 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2024-02-07 Bruno Haible + c-nstrftime: Add tests. + * tests/test-c-nstrftime.c: New file, based on tests/test-nstrftime.c. + * tests/test-c-nstrftime-1.sh: New file, based on + tests/test-nstrftime-1.sh. + * tests/test-c-nstrftime-2.sh: New file, based on + tests/test-nstrftime-2.sh. + * modules/c-nstrftime-tests: New file. + c-nstrftime: New module. Suggested by Paul Eggert. * lib/strftime.h (c_nstrftime): New declaration. diff --git a/modules/c-nstrftime-tests b/modules/c-nstrftime-tests new file mode 100644 index 0000000000..fda810d09b --- /dev/null +++ b/modules/c-nstrftime-tests @@ -0,0 +1,26 @@ +Files: +tests/test-c-nstrftime-1.sh +tests/test-c-nstrftime-2.sh +tests/test-c-nstrftime.c +tests/test-nstrftime.h +tests/macros.h +m4/locale-fr.m4 +m4/codeset.m4 + +Depends-on: +atoll +c99 +intprops +strerror + +configure.ac: +gt_LOCALE_FR +gt_LOCALE_FR_UTF8 + +Makefile.am: +TESTS += test-c-nstrftime-1.sh test-c-nstrftime-2.sh +TESTS_ENVIRONMENT += \ + LOCALE_FR='@LOCALE_FR@' \ + LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' +check_PROGRAMS += test-c-nstrftime +test_c_nstrftime_LDADD = $(LDADD) $(SETLOCALE_LIB) diff --git a/tests/test-c-nstrftime-1.sh b/tests/test-c-nstrftime-1.sh new file mode 100755 index 0000000000..34b70effd3 --- /dev/null +++ b/tests/test-c-nstrftime-1.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +LC_ALL=C ${CHECKER} ./test-c-nstrftime${EXEEXT} || exit 1 + +exit 0 diff --git a/tests/test-c-nstrftime-2.sh b/tests/test-c-nstrftime-2.sh new file mode 100755 index 0000000000..e2bf1fae60 --- /dev/null +++ b/tests/test-c-nstrftime-2.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +: "${LOCALE_FR=fr_FR}" +: "${LOCALE_FR_UTF8=fr_FR.UTF-8}" + +if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then + if test -f /usr/bin/localedef; then + echo "Skipping test: no locale for testing is installed" + else + echo "Skipping test: no locale for testing is supported" + fi + exit 77 +fi + +if test $LOCALE_FR != none; then + LC_ALL=$LOCALE_FR ${CHECKER} ./test-c-nstrftime${EXEEXT} || exit 1 +fi + +if test $LOCALE_FR_UTF8 != none; then + LC_ALL=$LOCALE_FR_UTF8 ${CHECKER} ./test-c-nstrftime${EXEEXT} || exit 1 +fi + +exit 0 diff --git a/tests/test-c-nstrftime.c b/tests/test-c-nstrftime.c new file mode 100644 index 0000000000..46ab58c92b --- /dev/null +++ b/tests/test-c-nstrftime.c @@ -0,0 +1,56 @@ +/* Test that c_nstrftime works as required. + 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 . */ + +/* Written by Jim Meyering. */ + +#include + +/* Specification. */ +#include "strftime.h" + +#include + +#include "intprops.h" + +#include +#include +#include +#include +#include +#include + +#include "macros.h" + +#define FUNC c_nstrftime +#include "test-nstrftime.h" + +int +main (void) +{ + /* Try to set the locale by implicitly looking at the LC_ALL environment + variable. + configure should already have checked that the locale is supported. */ + if (setlocale (LC_ALL, "") == NULL) + return 1; + + int fail = 0; + fail |= posixtm_test (); + fail |= tzalloc_test (); + fail |= quarter_test (); + fail |= errno_test (); + fail |= locales_test (english); + return fail; +}