From: Daiki Ueno Date: Thu, 15 May 2014 06:37:49 +0000 (+0900) Subject: tests: Add test for msgfilter plural handling X-Git-Tag: v0.19~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25d517520f5b28e5205811387e27809dc9eba968;p=thirdparty%2Fgettext.git tests: Add test for msgfilter plural handling --- diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 0641d2780..4eb30b334 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,9 @@ +2014-05-15 Daiki Ueno + + tests: Add test for msgfilter plural handling + * msgfilter-6: New test. + * Makefile.am (TESTS): Add new test. + 2014-05-15 Daiki Ueno tests: Add test for msgexec plural handling diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 10b3b7af6..6e6144b9d 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -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 index 000000000..81ef3185d --- /dev/null +++ b/gettext-tools/tests/msgfilter-6 @@ -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 </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