]> Savannah Git Hosting - gnulib.git/commitdiff
newlocale: Add tests.
authorBruno Haible <bruno@clisp.org>
Fri, 14 Feb 2025 01:52:01 +0000 (02:52 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 14 Feb 2025 01:53:40 +0000 (02:53 +0100)
* tests/test-newlocale.c: New file.
* modules/newlocale-tests: New file.

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

index 0e53a6e5315345c47b2859bf6c20be9abfa271d2..1a73e832dba72c4309f9e3a188fcb32006d624b7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-02-14  Bruno Haible  <bruno@clisp.org>
 
+       newlocale: Add tests.
+       * tests/test-newlocale.c: New file.
+       * modules/newlocale-tests: New file.
+
        newlocale: New module.
        * lib/locale.in.h (newlocale): Consider GNULIB_NEWLOCALE. Declare if
        not declared. Don't define HAVE_WORKING_NEWLOCALE.
diff --git a/modules/newlocale-tests b/modules/newlocale-tests
new file mode 100644 (file)
index 0000000..706003b
--- /dev/null
@@ -0,0 +1,12 @@
+Files:
+tests/test-newlocale.c
+tests/signature.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-newlocale
+check_PROGRAMS += test-newlocale
diff --git a/tests/test-newlocale.c b/tests/test-newlocale.c
new file mode 100644 (file)
index 0000000..fa21f8b
--- /dev/null
@@ -0,0 +1,56 @@
+/* Test of creating a locale object.
+   Copyright (C) 2025 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>, 2025.  */
+
+#include <config.h>
+
+#include <locale.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (newlocale, locale_t, (int, const char *, locale_t));
+
+#include "macros.h"
+
+#if defined _WIN32 && !defined __CYGWIN__
+
+# define ENGLISH  "English_United States"
+# define FRENCH   "French_France"
+# define GERMAN   "German_Germany"
+# define ENCODING ".1252"
+
+# define LOCALE1 ENGLISH ENCODING
+# define LOCALE2 FRENCH ENCODING
+# define LOCALE3 GERMAN ENCODING
+
+#else
+
+# define LOCALE1 "en_US.UTF-8"
+# define LOCALE2 "fr_FR.UTF-8"
+# define LOCALE3 "de_DE.UTF-8"
+
+#endif
+
+int
+main ()
+{
+  locale_t l1 = newlocale (LC_TIME_MASK, LOCALE1, NULL);
+  locale_t l2 = newlocale (LC_MESSAGES_MASK, LOCALE2, l1);
+  locale_t l3 = newlocale (LC_TIME_MASK, LOCALE3, l2);
+  (void) l3;
+
+  return test_exit_status;
+}