Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / format-qt-plural-1
1 #! /bin/sh
2
3 # Test recognition of Qt plural format strings.
4
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
7
8 tmpfiles="$tmpfiles f-qtp-1.data"
9 cat <<\EOF > f-qtp-1.data
10 # Unrecognized: no argument
11 "abcdef"
12 # Unrecognized: unterminated
13 "abcdef%"
14 # Unrecognized: unterminated
15 "abcdef%L"
16 # Valid: one argument
17 "abc%ndef"
18 # Valid: unterminated
19 "abc%ndef%"
20 # Valid: unterminated
21 "abc%ndef%L"
22 # Valid: multiple uses of same argument
23 "abc%ndef%nghi"
24 # Valid: an argument with locale-dependency flag
25 "abc%Lndef"
26 EOF
27
28 : ${XGETTEXT=xgettext}
29 n=0
30 while read comment; do
31   read string
32   n=`expr $n + 1`
33   tmpfiles="$tmpfiles f-qtp-1-$n.in f-qtp-1-$n.po"
34   cat <<EOF > f-qtp-1-$n.in
35 _(${string});
36 EOF
37   ${XGETTEXT} -L C++ --qt -k_ -o f-qtp-1-$n.po f-qtp-1-$n.in || exit 1
38   test -f f-qtp-1-$n.po || exit 1
39   fail=
40   if echo "$comment" | grep 'Valid:' > /dev/null; then
41     if grep qt-plural-format f-qtp-1-$n.po > /dev/null; then
42       :
43     else
44       fail=yes
45     fi
46   else
47     if grep qt-plural-format f-qtp-1-$n.po > /dev/null; then
48       fail=yes
49     else
50       :
51     fi
52   fi
53   if test -n "$fail"; then
54     echo "Format string recognition error:" 1>&2
55     cat f-qtp-1-$n.in 1>&2
56     echo "Got:" 1>&2
57     cat f-qtp-1-$n.po 1>&2
58     exit 1
59   fi
60   rm -f f-qtp-1-$n.in f-qtp-1-$n.po
61 done < f-qtp-1.data
62
63 rm -fr $tmpfiles
64
65 exit 0