]> Savannah Git Hosting - gnulib.git/commitdiff
c-nstrftime: Add tests.
authorBruno Haible <bruno@clisp.org>
Thu, 8 Feb 2024 00:24:12 +0000 (01:24 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 8 Feb 2024 00:25:32 +0000 (01:25 +0100)
* 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.

ChangeLog
modules/c-nstrftime-tests [new file with mode: 0644]
tests/test-c-nstrftime-1.sh [new file with mode: 0755]
tests/test-c-nstrftime-2.sh [new file with mode: 0755]
tests/test-c-nstrftime.c [new file with mode: 0644]

index 0d9b82b1e9463c121a656f04bf92b1d68b2a6a9b..53f6cb1765422cee735597e94481505ecad6cef5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 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.
diff --git a/modules/c-nstrftime-tests b/modules/c-nstrftime-tests
new file mode 100644 (file)
index 0000000..fda810d
--- /dev/null
@@ -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 (executable)
index 0000000..34b70ef
--- /dev/null
@@ -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 (executable)
index 0000000..e2bf1fa
--- /dev/null
@@ -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 (file)
index 0000000..46ab58c
--- /dev/null
@@ -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 <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;
+}