From: Bruno Haible Date: Sun, 29 Mar 2009 16:39:38 +0000 (+0000) Subject: Tests for gfc-internal-format. X-Git-Tag: v0.18~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8a370e3bea026f5b12f61bd907830fbce99dc4a;p=thirdparty%2Fgettext.git Tests for gfc-internal-format. --- diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 84930a663..f4d46bbcc 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,15 @@ +2009-03-29 Bruno Haible + + * format-gfc-internal-1: New file. + * format-gfc-internal-2: New file. + * Makefile.am (TESTS): Add them. + +2009-01-28 Bruno Haible + + * format-qt-plural-1: New file. + * format-qt-plural-2: New file. + * Makefile.am (TESTS): Add them. + 2009-01-27 Bruno Haible * xgettext-c-13: Test also the 3 variants of the tr function and the diff --git a/gettext-tools/tests/format-gfc-internal-1 b/gettext-tools/tests/format-gfc-internal-1 new file mode 100755 index 000000000..42bf8a077 --- /dev/null +++ b/gettext-tools/tests/format-gfc-internal-1 @@ -0,0 +1,109 @@ +#! /bin/sh + +# Test recognition of GFC internal format strings. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles f-gf-1.data" +cat <<\EOF > f-gf-1.data +# Valid: no argument +"abc%%" +# Valid: void argument +"abc%C" +# Valid: one locus argument +"abc%L" +# Valid: one character argument +"abc%c" +# Valid: one string argument +"abc%s" +# Valid: one integer argument +"abc%i" +# Valid: one integer argument +"abc%d" +# Valid: one integer argument +"abc%u" +# Valid: one argument with size specifier +"abc%li" +# Valid: one argument with size specifier +"abc%ld" +# Valid: one argument with size specifier +"abc%lu" +# Invalid: one argument with invalid size specifier +"abc%lli" +# Invalid: one argument with invalid size specifier +"abc%llu" +# Invalid: one argument with invalid size specifier +"abc%ls" +# Invalid: unterminated +"abc%" +# Invalid: unknown format specifier +"abc%y" +# Invalid: precision +"abc%.*s" +# Valid: three arguments +"abc%d%u%u" +# Valid: a numbered argument +"abc%1$d" +# Invalid: zero +"abc%0$d" +# Invalid: unterminated number +"abc%1" +# Valid: three arguments, two with same number +"abc%1$i,%2$c,%1$d" +# Invalid: argument with conflicting types +"abc%1$i,%2$c,%1$u" +# Valid: multiple uses of void argument +"abc%Cdef%dghi%C" +# Invalid: argument with conflicting types +"abc%1$i,%2$c,%1$C" +# Valid: mixing of numbered and unnumbered arguments +"abc%d%2$u" +# Invalid: missing non-final argument +"abc%2$u%3$s" +# Valid: non-final argument is void +"abc%C%2$u%3$s" +# Valid: permutation +"abc%2$ddef%1$d" +# Valid: multiple uses of same argument +"abc%2$udef%1$sghi%2$u" +EOF + +: ${XGETTEXT=xgettext} +n=0 +while read comment; do + read string + n=`expr $n + 1` + tmpfiles="$tmpfiles f-gf-1-$n.in f-gf-1-$n.po" + cat < f-gf-1-$n.in +gettext(${string}); +EOF + ${XGETTEXT} -L GCC-source -o f-gf-1-$n.po f-gf-1-$n.in || exit 1 + test -f f-gf-1-$n.po || exit 1 + fail= + if echo "$comment" | grep 'Valid:' > /dev/null; then + if grep gfc-internal-format f-gf-1-$n.po > /dev/null; then + : + else + fail=yes + fi + else + if grep gfc-internal-format f-gf-1-$n.po > /dev/null; then + fail=yes + else + : + fi + fi + if test -n "$fail"; then + echo "Format string recognition error:" 1>&2 + cat f-gf-1-$n.in 1>&2 + echo "Got:" 1>&2 + cat f-gf-1-$n.po 1>&2 + exit 1 + fi + rm -f f-gf-1-$n.in f-gf-1-$n.po +done < f-gf-1.data + +rm -fr $tmpfiles + +exit 0 diff --git a/gettext-tools/tests/format-gfc-internal-2 b/gettext-tools/tests/format-gfc-internal-2 new file mode 100755 index 000000000..3332e5388 --- /dev/null +++ b/gettext-tools/tests/format-gfc-internal-2 @@ -0,0 +1,184 @@ +#! /bin/sh + +# Test checking of GFC internal format strings. + +tmpfiles="" +trap 'rm -fr $tmpfiles' 1 2 3 15 + +tmpfiles="$tmpfiles f-gf-2.data" +cat <<\EOF > f-gf-2.data +# Valid: %% doesn't count +msgid "abc%%def" +msgstr "xyz" +# Invalid: %C consumes currentloc +msgid "abc%Cdef" +msgstr "xyz" +# Invalid: %C consumes currentloc +msgid "abc" +msgstr "xyz%Cuvw" +# Invalid: invalid msgstr +msgid "abc%%def" +msgstr "xyz%" +# Valid: same arguments +msgid "abc%s%udef" +msgstr "xyz%s%u" +# Valid: same arguments but in numbered syntax +msgid "abc%s%ddef" +msgstr "xyz%1$s%2$d" +# Valid: permutation +msgid "abc%s%d%cdef" +msgstr "xyz%3$c%2$d%1$s" +# Invalid: too few arguments +msgid "abc%sdef%u" +msgstr "xyz%s" +# Invalid: too many arguments +msgid "abc%udef" +msgstr "xyz%uvw%c" +# Invalid: missing argument +msgid "abc%2$sdef%1$u" +msgstr "xyz%1$u" +# Invalid: missing argument +msgid "abc%1$sdef%2$u" +msgstr "xyz%2$u" +# Invalid: added argument +msgid "abc%1$udef" +msgstr "xyz%1$uvw%2$c" +# Valid: type compatibility +msgid "abc%i" +msgstr "xyz%d" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%s" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%i" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%u" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%li" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%lu" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%c" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%i" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%u" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%li" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%lu" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%s" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%i" +msgstr "xyz%u" +# Invalid: type incompatibility +msgid "abc%i" +msgstr "xyz%li" +# Invalid: type incompatibility +msgid "abc%i" +msgstr "xyz%lu" +# Invalid: type incompatibility +msgid "abc%i" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%i" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%u" +msgstr "xyz%li" +# Invalid: type incompatibility +msgid "abc%u" +msgstr "xyz%lu" +# Invalid: type incompatibility +msgid "abc%u" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%u" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%li" +msgstr "xyz%lu" +# Invalid: type incompatibility +msgid "abc%li" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%li" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%lu" +msgstr "xyz%L" +# Invalid: type incompatibility +msgid "abc%lu" +msgstr "xyz%C" +# Invalid: type incompatibility +msgid "abc%L" +msgstr "xyz%C" +# Invalid: permutation +msgid "abc%sdef%c" +msgstr "abc%cdef%s" +# Valid: currentloc reference position does not matter +msgid "abc%sdef%C" +msgstr "abc%Cdef%s" +# Valid: currentloc reference may be repeated +msgid "abc%sdef%C" +msgstr "abc%sdef%Cghi%C" +# Valid: currentloc reference may be repeated and permuted +msgid "abc%Cdef%Cghi%s" +msgstr "abc%sdef%C" +EOF + +: ${MSGFMT=msgfmt} +n=0 +while read comment; do + read msgid_line + read msgstr_line + n=`expr $n + 1` + tmpfiles="$tmpfiles f-gf-2-$n.po f-gf-2-$n.mo" + cat < f-gf-2-$n.po +#, gfc-internal-format +${msgid_line} +${msgstr_line} +EOF + fail= + if echo "$comment" | grep 'Valid:' > /dev/null; then + if ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po; then + : + else + fail=yes + fi + else + ${MSGFMT} --check-format -o f-gf-2-$n.mo f-gf-2-$n.po 2> /dev/null + if test $? = 1; then + : + else + fail=yes + fi + fi + if test -n "$fail"; then + echo "Format string checking error:" 1>&2 + cat f-gf-2-$n.po 1>&2 + exit 1 + fi + rm -f f-gf-2-$n.po f-gf-2-$n.mo +done < f-gf-2.data + +rm -fr $tmpfiles + +exit 0