Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-pascal-1
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test recognition of Object Pascal format strings.
5
6 cat <<\EOF > f-op-1.data
7 # Valid: no argument
8 "abc%%"
9 # Valid: one string argument
10 "abc%s"
11 # Valid: one integer argument
12 "abc%d"
13 # Valid: one integer argument
14 "abc%X"
15 # Valid: one floating-point argument
16 "abc%e"
17 # Valid: one floating-point argument
18 "abc%f"
19 # Valid: one floating-point argument
20 "abc%g"
21 # Valid: one floating-point argument
22 "abc%n"
23 # Valid: one floating-point argument
24 "abc%m"
25 # Valid: one pointer argument
26 "abc%p"
27 # Valid: one argument with flags
28 "abc%-g"
29 # Valid: one argument with width
30 "abc%2g"
31 # Valid: one argument with width
32 "abc%*g"
33 # Valid: one argument with precision
34 "abc%.4g"
35 # Valid: one argument with precision
36 "abc%.*g"
37 # Valid: one argument with width and precision
38 "abc%14.4g"
39 # Valid: one argument with width and precision
40 "abc%14.*g"
41 # Valid: one argument with width and precision
42 "abc%*.4g"
43 # Valid: one argument with width and precision
44 "abc%*.*g"
45 # Invalid: unterminated
46 "abc%"
47 # Invalid: unknown format specifier
48 "abc%y"
49 # Invalid: flags after width
50 "abc%*-g"
51 # Invalid: twice precision
52 "abc%.4.2g"
53 # Valid: three arguments
54 "abc%d%x%x"
55 # Valid: a numbered argument
56 "abc%0:d"
57 # Valid: a numbered argument with omitted number
58 "abc%:d"
59 # Valid: two-digit numbered arguments
60 "abc%10:def%9:dgh%8:dij%7:dkl%6:dmn%5:dop%4:dqr%3:dst%2:duv%1:dwx%0:dyz"
61 # Invalid: unterminated number
62 "abc%1"
63 # Invalid: flags before number
64 "abc%-0:d"
65 # Valid: three arguments, two with same number
66 "abc%0:4e,%1:p,%0:g"
67 # Invalid: argument with conflicting types
68 "abc%0:4x,%1:p,%0:s"
69 # Invalid: argument with conflicting types
70 "abc%0:4e,%1:p,%0:d"
71 # Valid: argument with different but not conflicting types
72 "abc%0:4x,%1:p,%0:d"
73 # Valid: mixing of numbered and unnumbered arguments
74 "abc%d%1:x"
75 # Valid: numbered argument with constant precision
76 "abc%0:.9x"
77 # Valid: mixing of numbered and unnumbered arguments
78 "abc%3:.*x"
79 # Valid: missing non-final argument
80 "abc%1:x%3:s"
81 # Valid: permutation
82 "abc%1:ddef%0:d"
83 # Valid: multiple uses of same argument
84 "abc%2:xdef%1:pghi%2:x"
85 # Valid: one argument with width
86 "abc%1:*g"
87 # Valid: one argument with width and precision
88 "abc%2:*.*g"
89 EOF
90
91 : ${XGETTEXT=xgettext}
92 n=0
93 while read comment; do
94   read string
95   n=`expr $n + 1`
96   echo "x.y=${string}" | sed -e "s/\"/'/g" > f-op-1-$n.in
97   ${XGETTEXT} -L RST -o f-op-1-$n.po f-op-1-$n.in || exit 1
98   test -f f-op-1-$n.po || exit 1
99   fail=
100   if echo "$comment" | grep 'Valid:' > /dev/null; then
101     if grep object-pascal-format f-op-1-$n.po > /dev/null; then
102       :
103     else
104       fail=yes
105     fi
106   else
107     if grep object-pascal-format f-op-1-$n.po > /dev/null; then
108       fail=yes
109     else
110       :
111     fi
112   fi
113   if test -n "$fail"; then
114     echo "Format string recognition error:" 1>&2
115     cat f-op-1-$n.in 1>&2
116     echo "Got:" 1>&2
117     cat f-op-1-$n.po 1>&2
118     exit 1
119   fi
120   rm -f f-op-1-$n.in f-op-1-$n.po
121 done < f-op-1.data
122
123 exit 0