From 00fc06b32f41d296f54babf3b306466795cae1a3 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 5 May 2019 16:59:55 +0200 Subject: [PATCH] Add unit test for libintl_version. * 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 | 2 + gettext-tools/tests/Makefile.am | 5 ++- gettext-tools/tests/intl-version | 7 +++ gettext-tools/tests/intl-version-prg.c | 59 ++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 gettext-tools/tests/intl-version create mode 100644 gettext-tools/tests/intl-version-prg.c diff --git a/.gitignore b/.gitignore index 4639c28be..e524b0f7c 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 083adebae..6aa3d5636 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -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 index 000000000..42103bdb0 --- /dev/null +++ b/gettext-tools/tests/intl-version @@ -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 index 000000000..b6f0ff6b7 --- /dev/null +++ b/gettext-tools/tests/intl-version-prg.c @@ -0,0 +1,59 @@ +/* Test of public API of . + Copyright (C) 2019 Free Software Foundation, Inc. + Written by Bruno Haible , 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 . */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +/* Make sure we use the included libintl, not the system's one. */ +#undef _LIBINTL_H +#include "libgnuintl.h" + +#include +#include +#include + +/* 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; +} -- 2.47.2