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