]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
tests: Add test for msgfilter plural handling
authorDaiki Ueno <ueno@gnu.org>
Thu, 15 May 2014 06:37:49 +0000 (15:37 +0900)
committerDaiki Ueno <ueno@gnu.org>
Thu, 15 May 2014 06:39:33 +0000 (15:39 +0900)
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/msgfilter-6 [new file with mode: 0755]

index 0641d2780c53b7c4c8a60c822d1caf458ad1d261..4eb30b334cccfb76c161688011b13d7b67954e74 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-15  Daiki Ueno  <ueno@gnu.org>
+
+       tests: Add test for msgfilter plural handling
+       * msgfilter-6: New test.
+       * Makefile.am (TESTS): Add new test.
+
 2014-05-15  Daiki Ueno  <ueno@gnu.org>
 
        tests: Add test for msgexec plural handling
index 10b3b7af64d709830a9712d21691e2e1510024d3..6e6144b9dd51fcf8b381f4bc2b4726323e16f34b 100644 (file)
@@ -42,6 +42,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        msgen-1 msgen-2 msgen-3 msgen-4 \
        msgexec-1 msgexec-2 msgexec-3 msgexec-4 msgexec-5 \
        msgfilter-1 msgfilter-2 msgfilter-3 msgfilter-4 msgfilter-5 \
+       msgfilter-6 \
        msgfilter-sr-latin-1 msgfilter-quote-1 \
        msgfmt-1 msgfmt-2 msgfmt-3 msgfmt-4 msgfmt-5 msgfmt-6 msgfmt-7 \
        msgfmt-8 msgfmt-9 msgfmt-10 msgfmt-11 msgfmt-12 msgfmt-13 msgfmt-14 \
diff --git a/gettext-tools/tests/msgfilter-6 b/gettext-tools/tests/msgfilter-6
new file mode 100755 (executable)
index 0000000..81ef318
--- /dev/null
@@ -0,0 +1,83 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test msgfilter on a PO file with plurals.
+
+cat <<\EOF > mf-test6.po
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ASCII\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
+#, c-format
+msgid "'Your command, please?', asked the waiter."
+msgstr "'Votre commande, s'il vous plait', dit le garcon."
+
+# Les gateaux allemands sont les meilleurs du monde.
+#, c-format
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] "un morceau de gateau"
+msgstr[1] "%d morceaux de gateau"
+
+# Reverse the arguments.
+#, c-format
+msgid "%s is replaced by %s."
+msgstr "%2$s remplace %1$s."
+EOF
+
+: > mf-test6.tmp
+
+cat <<\EOF > mf-test6.sh
+#! /bin/sh
+echo "========================= $MSGFILTER_LOCATION =========================" >> mf-test6.tmp
+if test -n "${MSGFILTER_MSGCTXT+set}"; then
+  echo "context: $MSGFILTER_MSGCTXT" >> mf-test6.tmp
+fi
+cat >> mf-test6.tmp <<MEOF
+$MSGFILTER_MSGID
+$MSGFILTER_MSGID_PLURAL
+$MSGFILTER_PLURAL_FORM
+MEOF
+cat
+EOF
+chmod a+x mf-test6.sh
+
+: ${MSGFILTER=msgfilter}
+LC_ALL=C \
+${MSGFILTER} -i mf-test6.po ./mf-test6.sh >/dev/null 2> mf-test6.err
+result=$?
+
+cat mf-test6.err | grep -v 'warning: Locale charset' | grep -v '^ '
+test $result = 0 || { exit 1; }
+
+LC_ALL=C tr -d '\r' < mf-test6.tmp > mf-test6.out
+
+cat <<\EOF > mf-test6.ok
+========================= mf-test6.po:2 =========================
+
+
+
+========================= mf-test6.po:8 =========================
+'Your command, please?', asked the waiter.
+
+
+========================= mf-test6.po:14 =========================
+a piece of cake
+%d pieces of cake
+0
+========================= mf-test6.po:14 =========================
+a piece of cake
+%d pieces of cake
+1
+========================= mf-test6.po:20 =========================
+%s is replaced by %s.
+
+
+EOF
+
+: ${DIFF=diff}
+${DIFF} mf-test6.ok mf-test6.out
+result=$?
+
+exit $result