* 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.
2024-02-07 Bruno Haible <bruno@clisp.org>
+ 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.
--- /dev/null
+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)
--- /dev/null
+#!/bin/sh
+
+LC_ALL=C ${CHECKER} ./test-c-nstrftime${EXEEXT} || exit 1
+
+exit 0
--- /dev/null
+#!/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
--- /dev/null
+/* 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 <https://www.gnu.org/licenses/>. */
+
+/* Written by Jim Meyering. */
+
+#include <config.h>
+
+/* Specification. */
+#include "strftime.h"
+
+#include <locale.h>
+
+#include "intprops.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <unistd.h>
+
+#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;
+}