]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Add unit test for libintl_version.
authorBruno Haible <bruno@clisp.org>
Sun, 5 May 2019 14:59:55 +0000 (16:59 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 5 May 2019 16:39:51 +0000 (18:39 +0200)
* gettext-tools/tests/intl-version-prg.c: New file.
* gettext-tools/tests/intl-version: New file.
* gettext-tools/tests/Makefile.am (TESTS): Add it.
(check_PROGRAMS): Add intl-version-prg.
(intl_version_prg_SOURCES, intl_version_prg_LDADD): New variables.

.gitignore
gettext-tools/tests/Makefile.am
gettext-tools/tests/intl-version [new file with mode: 0755]
gettext-tools/tests/intl-version-prg.c [new file with mode: 0644]

index 4639c28be1c931ab3157313fd31e699d43241940..e524b0f7cf106615627dc96159145cc0ca30ae0a 100644 (file)
@@ -695,6 +695,8 @@ autom4te.cache/
 /gettext-tools/tests/intl-thread-2-prg.exe
 /gettext-tools/tests/intl-thread-3-prg
 /gettext-tools/tests/intl-thread-3-prg.exe
+/gettext-tools/tests/intl-version-prg
+/gettext-tools/tests/intl-version-prg.exe
 /gettext-tools/tests/sentence-1-prg
 /gettext-tools/tests/sentence-1-prg.exe
 /gettext-tools/tests/testlocale
index 083adebaeb8c62c800233b0a3d37c9588f1d0ab1..6aa3d563625b77ffe8d888be2688c4871a74fe7f 100644 (file)
@@ -24,6 +24,7 @@ TESTS = gettext-1 gettext-2 \
        intl-1 intl-2 intl-3 intl-4 intl-5 \
        intl-setlocale-1 intl-setlocale-2 \
        intl-thread-1 intl-thread-2 intl-thread-3 \
+       intl-version \
        msgattrib-1 msgattrib-2 msgattrib-3 msgattrib-4 msgattrib-5 \
        msgattrib-6 msgattrib-7 msgattrib-8 msgattrib-9 msgattrib-10 \
        msgattrib-11 msgattrib-12 msgattrib-13 msgattrib-14 msgattrib-15 \
@@ -232,7 +233,7 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
 LDADD = $(LDADD_@USE_INCLUDED_LIBINTL@) @INTL_MACOSX_LIBS@
 LDADD_yes = ../intl/libintl.la @LTLIBTHREAD@
 LDADD_no = ../intl/libgnuintl.la @LTLIBTHREAD@ @LTLIBINTL@
-check_PROGRAMS = tstgettext tstngettext testlocale intl-1-prg intl-3-prg intl-4-prg intl-5-prg intl-setlocale-1-prg intl-setlocale-2-prg intl-thread-1-prg intl-thread-2-prg intl-thread-3-prg cake fc3 fc4 fc5 gettextpo-1-prg sentence-1-prg
+check_PROGRAMS = tstgettext tstngettext testlocale intl-1-prg intl-3-prg intl-4-prg intl-5-prg intl-setlocale-1-prg intl-setlocale-2-prg intl-thread-1-prg intl-thread-2-prg intl-thread-3-prg intl-version-prg cake fc3 fc4 fc5 gettextpo-1-prg sentence-1-prg
 tstgettext_SOURCES = tstgettext.c setlocale.c
 tstgettext_CFLAGS = -DINSTALLDIR=\".\"
 tstgettext_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
@@ -267,6 +268,8 @@ intl_thread_3_prg_CFLAGS = $(intl_thread_3_prg_CFLAGS_@HAVE_NEWLOCALE@)
 intl_thread_3_prg_CFLAGS_1 = -DUSE_POSIX_THREADS
 intl_thread_3_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD) $(intl_thread_3_prg_LDADD_@HAVE_NEWLOCALE@)
 intl_thread_3_prg_LDADD_1 = -lpthread
+intl_version_prg_SOURCES = intl-version-prg.c
+intl_version_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
 cake_SOURCES = plural-1-prg.c setlocale.c
 cake_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
 fc3_SOURCES = format-c-3-prg.c setlocale.c
diff --git a/gettext-tools/tests/intl-version b/gettext-tools/tests/intl-version
new file mode 100755 (executable)
index 0000000..42103bd
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test that libintl_version has the expected value,
+# even when --enable-shared is used on Windows.
+
+../intl-version-prg
diff --git a/gettext-tools/tests/intl-version-prg.c b/gettext-tools/tests/intl-version-prg.c
new file mode 100644 (file)
index 0000000..b6f0ff6
--- /dev/null
@@ -0,0 +1,59 @@
+/* Test of public API of <libintl.h>.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2019.
+
+   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/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+/* Make sure we use the included libintl, not the system's one. */
+#undef _LIBINTL_H
+#include "libgnuintl.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Use the system functions, not the gnulib overrides in this file.  */
+#undef fflush
+#undef fprintf
+
+#define ASSERT(expr) \
+  do                                                                         \
+    {                                                                        \
+      if (!(expr))                                                           \
+        {                                                                    \
+          fprintf (stderr, "%s:%d: assertion failed\n",                      \
+                   __FILE__, __LINE__);                                      \
+          fflush (stderr);                                                   \
+          abort ();                                                          \
+        }                                                                    \
+    }                                                                        \
+  while (0)
+
+int
+main (int argc, char *argv[])
+{
+  /* Test LIBINTL_VERSION.  */
+  {
+    enum { version = LIBINTL_VERSION };
+  }
+
+  /* Test libintl_version.  */
+  ASSERT (libintl_version == LIBINTL_VERSION);
+
+  return 0;
+}