]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Test the handling of 'range:' flags.
authorBruno Haible <bruno@clisp.org>
Sat, 4 Oct 2008 11:33:40 +0000 (11:33 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:15:54 +0000 (12:15 +0200)
gettext-tools/tests/Makefile.am
gettext-tools/tests/msgcat-18 [new file with mode: 0755]
gettext-tools/tests/msgcomm-27 [new file with mode: 0755]
gettext-tools/tests/msgmerge-24 [new file with mode: 0755]
gettext-tools/tests/xgettext-c-18 [new file with mode: 0755]

index e095872a303f426ff7e2a32a5d3f6bb8a336cd39..138b1db1fd1f344c545680b1d340c9dc7991d5cb 100644 (file)
@@ -29,7 +29,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        msgattrib-properties-1 \
        msgcat-1 msgcat-2 msgcat-3 msgcat-4 msgcat-5 msgcat-6 msgcat-7 \
        msgcat-8 msgcat-9 msgcat-10 msgcat-11 msgcat-12 msgcat-13 msgcat-14 \
-       msgcat-15 msgcat-16 msgcat-17 \
+       msgcat-15 msgcat-16 msgcat-17 msgcat-18 \
        msgcat-properties-1 msgcat-properties-2 \
        msgcat-stringtable-1 \
        msgcmp-1 msgcmp-2 msgcmp-3 msgcmp-4 \
@@ -37,7 +37,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        msgcomm-8 msgcomm-9 msgcomm-10 msgcomm-11 msgcomm-12 msgcomm-13 \
        msgcomm-14 msgcomm-15 msgcomm-16 msgcomm-17 msgcomm-18 msgcomm-19 \
        msgcomm-20 msgcomm-21 msgcomm-22 msgcomm-23 msgcomm-24 msgcomm-25 \
-       msgcomm-26 \
+       msgcomm-26 msgcomm-27 \
        msgconv-1 msgconv-2 msgconv-3 msgconv-4 msgconv-5 msgconv-6 \
        msgen-1 msgen-2 msgen-3 \
        msgexec-1 msgexec-2 msgexec-3 msgexec-4 \
@@ -55,7 +55,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        msgmerge-7 msgmerge-8 msgmerge-9 msgmerge-10 msgmerge-11 msgmerge-12 \
        msgmerge-13 msgmerge-14 msgmerge-15 msgmerge-16 msgmerge-17 \
        msgmerge-18 msgmerge-19 msgmerge-20 msgmerge-21 msgmerge-22 \
-       msgmerge-23 \
+       msgmerge-23 msgmerge-24 \
        msgmerge-compendium-1 msgmerge-compendium-2 msgmerge-compendium-3 \
        msgmerge-compendium-4 msgmerge-compendium-5 msgmerge-compendium-6 \
        msgmerge-properties-1 msgmerge-properties-2 \
@@ -74,7 +74,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        xgettext-c-1 xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 \
        xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 xgettext-c-10 \
        xgettext-c-11 xgettext-c-12 xgettext-c-13 xgettext-c-14 xgettext-c-15 \
-       xgettext-c-16 xgettext-c-17 \
+       xgettext-c-16 xgettext-c-17 xgettext-c-18 \
        xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \
        xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \
        xgettext-csharp-7 \
diff --git a/gettext-tools/tests/msgcat-18 b/gettext-tools/tests/msgcat-18
new file mode 100755 (executable)
index 0000000..088069b
--- /dev/null
@@ -0,0 +1,100 @@
+#! /bin/sh
+
+# Test msgcat: handling of 'range:' flags.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles mcat-test18.in1 mcat-test18.in2"
+cat <<\EOF > mcat-test18.in1
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..6
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..7
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..6
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+cat <<\EOF > mcat-test18.in2
+#, c-format, range: 1..6
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..6
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+tmpfiles="$tmpfiles mcat-test18.tmp mcat-test18.out"
+rm -f mcat-test18.tmp
+: ${MSGCAT=msgcat}
+${MSGCAT} -o mcat-test18.tmp mcat-test18.in1 mcat-test18.in2
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < mcat-test18.tmp > mcat-test18.out
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles mcat-test18.ok"
+cat <<\EOF > mcat-test18.ok
+#, c-format
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..7
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} mcat-test18.ok mcat-test18.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
diff --git a/gettext-tools/tests/msgcomm-27 b/gettext-tools/tests/msgcomm-27
new file mode 100755 (executable)
index 0000000..09d423d
--- /dev/null
@@ -0,0 +1,99 @@
+#! /bin/sh
+
+# Test handling of format and 'range:' flag.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles mcomm-test27.in1 mcomm-test27.in2"
+cat <<EOF > mcomm-test27.in1
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..6
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..7
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..6
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+cat <<EOF > mcomm-test27.in2
+#, c-format, range: 1..6
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..6
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+tmpfiles="$tmpfiles mcomm-test27.tmp mcomm-test27.out"
+: ${MSGCOMM=msgcomm}
+${MSGCOMM} -o mcomm-test27.tmp mcomm-test27.in1 mcomm-test27.in2
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < mcomm-test27.tmp > mcomm-test27.out
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles mcomm-test27.ok"
+cat << EOF > mcomm-test27.ok
+#, c-format
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..7
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} mcomm-test27.ok mcomm-test27.out
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
diff --git a/gettext-tools/tests/msgmerge-24 b/gettext-tools/tests/msgmerge-24
new file mode 100755 (executable)
index 0000000..9564781
--- /dev/null
@@ -0,0 +1,174 @@
+#! /bin/sh
+
+# Test msgmerge and msgcmp: handling of 'range:' flags.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles mm-test24.po"
+cat <<\EOF > mm-test24.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] "un jour"
+msgstr[1] "%d jours"
+
+#, c-format, range: 1..6
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] "une semaine et un jour"
+msgstr[1] "une semaine et %d jours"
+
+#, c-format, range: 1..7
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] "deux semaines et un jour"
+msgstr[1] "deux semaines et %d jours"
+
+#, c-format, range: 0..6
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] "trois semaines et un jour"
+msgstr[1] "trois semaines et %d jours"
+
+#, c-format, range: 0..7
+msgid "four weeks and one day"
+msgid_plural "four weeks and %d days"
+msgstr[0] "quatre semaines et un jour"
+msgstr[1] "quatre semaines et %d jours"
+
+#, c-format, range: 1..6
+msgid "five weeks and one day"
+msgid_plural "five weeks and %d days"
+msgstr[0] "cinq semaines et un jour"
+msgstr[1] "cinq semaines et %d jours"
+EOF
+
+tmpfiles="$tmpfiles mm-test24.pot"
+cat <<\EOF > mm-test24.pot
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format, range: 1..6
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..6
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 1..6
+msgid "four weeks and one day"
+msgid_plural "four weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+
+#, c-format, range: 0..7
+msgid "five weeks and one day"
+msgid_plural "five weeks and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+: ${MSGCMP=msgcmp}
+${MSGCMP} --use-fuzzy --use-untranslated mm-test24.po mm-test24.pot 2>/dev/null
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles mm-test24.tmp.po mm-test24.new.po"
+: ${MSGMERGE=msgmerge}
+${MSGMERGE} -q -o mm-test24.tmp.po mm-test24.po mm-test24.pot
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < mm-test24.tmp.po > mm-test24.new.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles mm-test24.ok"
+cat <<\EOF > mm-test24.ok
+msgid ""
+msgstr ""
+"Report-Msgid-Bugs-To: \n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#, c-format, range: 1..6
+msgid "one day"
+msgid_plural "%d days"
+msgstr[0] "un jour"
+msgstr[1] "%d jours"
+
+#, fuzzy, c-format
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] "une semaine et un jour"
+msgstr[1] "une semaine et %d jours"
+
+#, fuzzy, c-format, range: 0..6
+msgid "two weeks and one day"
+msgid_plural "two weeks and %d days"
+msgstr[0] "deux semaines et un jour"
+msgstr[1] "deux semaines et %d jours"
+
+#, fuzzy, c-format, range: 1..7
+msgid "three weeks and one day"
+msgid_plural "three weeks and %d days"
+msgstr[0] "trois semaines et un jour"
+msgstr[1] "trois semaines et %d jours"
+
+#, c-format, range: 1..6
+msgid "four weeks and one day"
+msgid_plural "four weeks and %d days"
+msgstr[0] "quatre semaines et un jour"
+msgstr[1] "quatre semaines et %d jours"
+
+#, fuzzy, c-format, range: 0..7
+msgid "five weeks and one day"
+msgid_plural "five weeks and %d days"
+msgstr[0] "cinq semaines et un jour"
+msgstr[1] "cinq semaines et %d jours"
+EOF
+
+: ${DIFF=diff}
+${DIFF} mm-test24.ok mm-test24.new.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+: ${MSGCMP=msgcmp}
+${MSGCMP} --use-fuzzy --use-untranslated mm-test24.new.po mm-test24.pot
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+rm -fr $tmpfiles
+
+exit 0
diff --git a/gettext-tools/tests/xgettext-c-18 b/gettext-tools/tests/xgettext-c-18
new file mode 100755 (executable)
index 0000000..62457a2
--- /dev/null
@@ -0,0 +1,39 @@
+#! /bin/sh
+
+# Test C support: extraction of 'range:' flags.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles xg-c-18.c"
+cat <<\EOF > xg-c-18.c
+if (days > 7 && days < 14)
+  /* xgettext: range: 1..6 */
+  printf (ngettext ("one week and one day", "one week and %d days",
+                    days - 7),
+          days - 7);
+EOF
+
+tmpfiles="$tmpfiles xg-c-18.tmp.po xg-c-18.po"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -d xg-c-18.tmp xg-c-18.c
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < xg-c-18.tmp.po > xg-c-18.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-c-18.ok"
+cat <<EOF > xg-c-18.ok
+#, c-format, range: 1..6
+msgid "one week and one day"
+msgid_plural "one week and %d days"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-c-18.ok xg-c-18.po
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result