]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
New test intl-3.
authorBruno Haible <bruno@clisp.org>
Sat, 20 Oct 2018 12:29:29 +0000 (14:29 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 21 Oct 2018 18:30:43 +0000 (20:30 +0200)
* gettext-tools/tests/intl-3: New file.
* gettext-tools/tests/intl-3-prg.c: New file.
* gettext-tools/tests/Makefile.amL Update.

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

index 68a761d470d5ec731f4ec14dfd40ceef9547bcfb..6d0f6580387dedf444b23215d5efc964981d46ed 100644 (file)
@@ -673,6 +673,8 @@ autom4te.cache/
 /gettext-tools/tests/gettextpo-1-prg.exe
 /gettext-tools/tests/intl-1-prg
 /gettext-tools/tests/intl-1-prg.exe
+/gettext-tools/tests/intl-3-prg
+/gettext-tools/tests/intl-3-prg.exe
 /gettext-tools/tests/intl-setlocale-1-prg
 /gettext-tools/tests/intl-setlocale-1-prg.exe
 /gettext-tools/tests/sentence-1-prg
index a96a9b5ac84c22bb76743316f8c8d9577d4515ee..d1c145dec5b4c65e92395486b4ffecbc931e526e 100644 (file)
@@ -21,7 +21,7 @@ EXTRA_DIST =
 MOSTLYCLEANFILES = core *.stackdump
 
 TESTS = gettext-1 gettext-2 \
-       intl-1 intl-2 \
+       intl-1 intl-2 intl-3 \
        intl-setlocale-1 \
        gettext-4 gettext-5 gettext-6 gettext-7 gettext-8 \
        msgattrib-1 msgattrib-2 msgattrib-3 msgattrib-4 msgattrib-5 \
@@ -222,7 +222,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-setlocale-1-prg gettext-4-prg gettext-5-prg gettext-6-prg gettext-7-prg gettext-8-prg cake fc3 fc4 fc5 gettextpo-1-prg sentence-1-prg
+check_PROGRAMS = tstgettext tstngettext testlocale intl-1-prg intl-3-prg intl-setlocale-1-prg gettext-4-prg gettext-5-prg gettext-6-prg gettext-7-prg gettext-8-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)
@@ -232,6 +232,8 @@ tstngettext_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
 testlocale_SOURCES = testlocale.c
 intl_1_prg_SOURCES = intl-1-prg.c
 intl_1_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
+intl_3_prg_SOURCES = intl-3-prg.c
+intl_3_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
 intl_setlocale_1_prg_SOURCES = intl-setlocale-1-prg.c
 intl_setlocale_1_prg_LDADD = ../gnulib-lib/libgettextlib.la $(LDADD)
 gettext_4_prg_SOURCES = gettext-4-prg.c
diff --git a/gettext-tools/tests/intl-3 b/gettext-tools/tests/intl-3
new file mode 100755 (executable)
index 0000000..d332319
--- /dev/null
@@ -0,0 +1,63 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test that bind_textdomain_codeset() works.
+
+test -d in-3-1 || mkdir in-3-1
+test -d in-3-1/fr || mkdir in-3-1/fr
+test -d in-3-1/fr/LC_MESSAGES || mkdir in-3-1/fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o in-3-1/fr/LC_MESSAGES/tstprog.mo "$abs_srcdir"/intl-2-1.po
+
+test -d in-3-2 || mkdir in-3-2
+test -d in-3-2/fr || mkdir in-3-2/fr
+test -d in-3-2/fr/LC_MESSAGES || mkdir in-3-2/fr/LC_MESSAGES
+
+: ${MSGFMT=msgfmt}
+${MSGFMT} -o in-3-2/fr/LC_MESSAGES/tstprog.mo "$abs_srcdir"/intl-2-2.po
+
+: ${DIFF=diff}
+cat <<EOF > in-3-1.ok
+Käse
+EOF
+cat <<EOF > in-3-2.ok
+Käse
+EOF
+
+: ${LOCALE_FR=fr_FR}
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR != none; then
+  prepare_locale_ in-3-1/fr in-3-1/$LOCALE_FR
+  prepare_locale_ in-3-2/fr in-3-2/$LOCALE_FR
+  ../intl-3-prg in-3-1 $LOCALE_FR ISO-8859-1 > in-3.out || Exit 1
+  ${DIFF} in-3-1.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-2 $LOCALE_FR ISO-8859-1 > in-3.out || Exit 1
+  ${DIFF} in-3-1.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-1 $LOCALE_FR UTF-8 > in-3.out || Exit 1
+  ${DIFF} in-3-2.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-2 $LOCALE_FR UTF-8 > in-3.out || Exit 1
+  ${DIFF} in-3-2.ok in-3.out || Exit 1
+fi
+if test $LOCALE_FR_UTF8 != none; then
+  prepare_locale_ in-3-1/fr in-3-1/$LOCALE_FR_UTF8
+  prepare_locale_ in-3-2/fr in-3-2/$LOCALE_FR_UTF8
+  ../intl-3-prg in-3-1 $LOCALE_FR_UTF8 ISO-8859-1 > in-3.out || Exit 1
+  ${DIFF} in-3-1.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-2 $LOCALE_FR_UTF8 ISO-8859-1 > in-3.out || Exit 1
+  ${DIFF} in-3-1.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-1 $LOCALE_FR_UTF8 UTF-8 > in-3.out || Exit 1
+  ${DIFF} in-3-2.ok in-3.out || Exit 1
+  ../intl-3-prg in-3-2 $LOCALE_FR_UTF8 UTF-8 > in-3.out || Exit 1
+  ${DIFF} in-3-2.ok in-3.out || Exit 1
+fi
+if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french locale is installed"
+  else
+    echo "Skipping test: no french locale is supported"
+  fi
+  Exit 77
+fi
+
+Exit 0
diff --git a/gettext-tools/tests/intl-3-prg.c b/gettext-tools/tests/intl-3-prg.c
new file mode 100644 (file)
index 0000000..19c7603
--- /dev/null
@@ -0,0 +1,54 @@
+/* Test program, used by the intl-3 test.
+   Copyright (C) 2000, 2005, 2007, 2015-2016, 2018 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/>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <locale.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "xsetenv.h"
+
+/* Make sure we use the included libintl, not the system's one. */
+#undef _LIBINTL_H
+#include "libgnuintl.h"
+
+int
+main (int argc, char *argv[])
+{
+  const char *dir = argv[1];
+  const char *locale = argv[2];
+  const char *codeset = argv[3];
+
+  /* Clean up environment.  */
+  unsetenv ("LANGUAGE");
+  unsetenv ("OUTPUT_CHARSET");
+
+  textdomain ("tstprog");
+
+  xsetenv ("LC_ALL", locale, 1);
+  if (setlocale (LC_ALL, "") == NULL)
+    setlocale (LC_ALL, "C");
+
+  bindtextdomain ("tstprog", dir);
+
+  bind_textdomain_codeset ("tstprog", codeset);
+
+  printf ("%s\n", gettext ("cheese"));
+
+  return 0;
+}