From 70501a1599a3f4052fac1801263d6cc168fb17e0 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Thu, 15 May 2014 15:18:35 +0900 Subject: [PATCH] tests: Add test for msgexec plural handling --- gettext-tools/tests/ChangeLog | 6 +++ gettext-tools/tests/Makefile.am | 2 +- gettext-tools/tests/msgexec-5 | 93 +++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100755 gettext-tools/tests/msgexec-5 diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 51dacf865..0641d2780 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,9 @@ +2014-05-15 Daiki Ueno + + tests: Add test for msgexec plural handling + * msgexec-5: New test. + * Makefile.am (TESTS): Add new test. + 2014-05-15 Daiki Ueno * msginit-3: Fix charset value after msginit invocation. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index 2dcf43946..10b3b7af6 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -40,7 +40,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \ msgcomm-26 msgcomm-27 msgcomm-28 \ msgconv-1 msgconv-2 msgconv-3 msgconv-4 msgconv-5 msgconv-6 msgconv-7 \ msgen-1 msgen-2 msgen-3 msgen-4 \ - msgexec-1 msgexec-2 msgexec-3 msgexec-4 \ + msgexec-1 msgexec-2 msgexec-3 msgexec-4 msgexec-5 \ msgfilter-1 msgfilter-2 msgfilter-3 msgfilter-4 msgfilter-5 \ msgfilter-sr-latin-1 msgfilter-quote-1 \ msgfmt-1 msgfmt-2 msgfmt-3 msgfmt-4 msgfmt-5 msgfmt-6 msgfmt-7 \ diff --git a/gettext-tools/tests/msgexec-5 b/gettext-tools/tests/msgexec-5 new file mode 100755 index 000000000..1b9dac646 --- /dev/null +++ b/gettext-tools/tests/msgexec-5 @@ -0,0 +1,93 @@ +#! /bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test msgexec on a PO file with plurals. + +cat <<\EOF > mex-test5.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 + +cat <<\EOF > mex-test5.sh +#! /bin/sh +echo "========================= $MSGEXEC_LOCATION =========================" | LC_ALL=C tr -d '\r' +if test -n "${MSGEXEC_MSGCTXT+set}"; then + echo "context: $MSGEXEC_MSGCTXT" | LC_ALL=C tr -d '\r' +fi +cat < mex-test5.out 2> mex-test5.err +result=$? +cat mex-test5.err | grep -v 'warning: Locale charset' | grep -v '^ ' +test $result = 0 || { exit 1; } + +cat <<\EOF > mex-test5.ok +========================= mex-test5.po:2 ========================= + + + +--- +Content-Type: text/plain; charset=ASCII +Plural-Forms: nplurals=2; plural=(n > 1); + +========================= mex-test5.po:8 ========================= +'Your command, please?', asked the waiter. + + +--- +'Votre commande, s'il vous plait', dit le garcon. +========================= mex-test5.po:14 ========================= +a piece of cake +%d pieces of cake +0 +--- +un morceau de gateau +========================= mex-test5.po:14 ========================= +a piece of cake +%d pieces of cake +1 +--- +%d morceaux de gateau +========================= mex-test5.po:20 ========================= +%s is replaced by %s. + + +--- +%2$s remplace %1$s. +EOF + +: ${DIFF=diff} +${DIFF} mex-test5.ok mex-test5.out +result=$? + +exit $result -- 2.47.2