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