]> Savannah Git Hosting - gnulib.git/commitdiff
tzname: Add tests.
authorBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 16:05:57 +0000 (18:05 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 6 Jun 2024 23:32:59 +0000 (01:32 +0200)
* tests/test-tzname.c: New file.
* modules/tzname-tests: New file.

ChangeLog
modules/tzname-tests [new file with mode: 0644]
tests/test-tzname.c [new file with mode: 0644]

index 6078703f6a7fe0d48e93c2ad33ea95543cae6ff1..eb8dde396b07f25632ad9c0620b681e0611b7b94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-06-06  Bruno Haible  <bruno@clisp.org>
 
+       tzname: Add tests.
+       * tests/test-tzname.c: New file.
+       * modules/tzname-tests: New file.
+
        tzname: New module.
        * lib/time.in.h (tzname): New declaration.
        * m4/tzname.m4: New file.
diff --git a/modules/tzname-tests b/modules/tzname-tests
new file mode 100644 (file)
index 0000000..b2c590e
--- /dev/null
@@ -0,0 +1,11 @@
+Files:
+tests/test-tzname.c
+
+Depends-on:
+tzset
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-tzname
+check_PROGRAMS += test-tzname
diff --git a/tests/test-tzname.c b/tests/test-tzname.c
new file mode 100644 (file)
index 0000000..385d594
--- /dev/null
@@ -0,0 +1,36 @@
+/* Test of tzname array.
+   Copyright (C) 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 <bruno@clisp.org>, 2024.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <time.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  const char *tz = getenv ("TZ");
+  tzset ();
+  printf ("TZ=%s -> tzname[0]=\"%s\", tzname[1]=\"%s\"\n",
+          tz != NULL ? tz : "(null)",
+          tzname[0], tzname[1]);
+  return 0;
+}