Add -lm dependency for gettextlib to fix LTO build
[platform/upstream/gettext.git] / gettext-tools / tests / format-boost-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of Boost format strings.
5
6 cat <<\EOF > f-bo-2.data
7 # Valid: %% doesn't count
8 msgid  "abc%%def"
9 msgstr "xyz"
10 # Invalid: invalid msgstr
11 msgid  "abc%%def"
12 msgstr "xyz%"
13 # Valid: same arguments
14 msgid  "abc%s%gdef"
15 msgstr "xyz%s%g"
16 # Valid: same arguments, despite different syntax
17 msgid  "abc%s%gdef"
18 msgstr "xyz%|s|%|g|"
19 # Valid: same arguments, with different widths
20 msgid  "abc%2sdef"
21 msgstr "xyz%3s"
22 # Valid: same arguments but in numbered syntax
23 msgid  "abc%s%gdef"
24 msgstr "xyz%1$s%2$g"
25 # Valid: same arguments but in numbered syntax
26 msgid  "abc%s%gdef"
27 msgstr "xyz%1%%2$g"
28 # Valid: permutation
29 msgid  "abc%s%g%cdef"
30 msgstr "xyz%3$c%2$g%1$s"
31 # Invalid: too few arguments
32 msgid  "abc%2$udef%1$s"
33 msgstr "xyz%1$s"
34 # Invalid: too few arguments
35 msgid  "abc%sdef%u"
36 msgstr "xyz%s"
37 # Invalid: too many arguments
38 msgid  "abc%udef"
39 msgstr "xyz%uvw%c"
40 # Valid: same numbered arguments, with different widths
41 msgid  "abc%2$5s%1$4s"
42 msgstr "xyz%2$4s%1$5s"
43 # Invalid: missing argument
44 msgid  "abc%2$sdef%1$u"
45 msgstr "xyz%1$u"
46 # Invalid: missing argument
47 msgid  "abc%1$sdef%2$u"
48 msgstr "xyz%2$u"
49 # Invalid: added argument
50 msgid  "abc%1$udef"
51 msgstr "xyz%1$uvw%2$c"
52 # Valid: type compatibility
53 msgid  "abc%i"
54 msgstr "xyz%d"
55 # Valid: type compatibility
56 msgid  "abc%i"
57 msgstr "xyz%o"
58 # Valid: type compatibility
59 msgid  "abc%i"
60 msgstr "xyz%u"
61 # Valid: type compatibility
62 msgid  "abc%i"
63 msgstr "xyz%x"
64 # Valid: type compatibility
65 msgid  "abc%i"
66 msgstr "xyz%X"
67 # Valid: type compatibility
68 msgid  "abc%e"
69 msgstr "xyz%E"
70 # Valid: type compatibility
71 msgid  "abc%e"
72 msgstr "xyz%f"
73 # Valid: type compatibility
74 msgid  "abc%e"
75 msgstr "xyz%g"
76 # Valid: type compatibility
77 msgid  "abc%e"
78 msgstr "xyz%G"
79 # Invalid: type incompatibility
80 msgid  "abc%c"
81 msgstr "xyz%s"
82 # Invalid: type incompatibility
83 msgid  "abc%c"
84 msgstr "xyz%i"
85 # Invalid: type incompatibility
86 msgid  "abc%c"
87 msgstr "xyz%e"
88 # Invalid: type incompatibility
89 msgid  "abc%c"
90 msgstr "xyz%p"
91 # Invalid: different argument count
92 msgid  "abc%c"
93 msgstr "xyz%n"
94 # Invalid: type incompatibility
95 msgid  "abc%s"
96 msgstr "xyz%i"
97 # Invalid: type incompatibility
98 msgid  "abc%s"
99 msgstr "xyz%e"
100 # Invalid: type incompatibility
101 msgid  "abc%s"
102 msgstr "xyz%p"
103 # Invalid: different argument count
104 msgid  "abc%s"
105 msgstr "xyz%n"
106 # Invalid: type incompatibility
107 msgid  "abc%i"
108 msgstr "xyz%e"
109 # Invalid: type incompatibility
110 msgid  "abc%i"
111 msgstr "xyz%p"
112 # Invalid: different argument count
113 msgid  "abc%i"
114 msgstr "xyz%n"
115 # Invalid: type incompatibility
116 msgid  "abc%e"
117 msgstr "xyz%p"
118 # Invalid: different argument count
119 msgid  "abc%e"
120 msgstr "xyz%n"
121 # Invalid: different argument count
122 msgid  "abc%p"
123 msgstr "xyz%n"
124 # Valid: size is ignored
125 msgid  "abc%i"
126 msgstr "xyz%hhi"
127 # Valid: size is ignored
128 msgid  "abc%i"
129 msgstr "xyz%hi"
130 # Valid: size is ignored
131 msgid  "abc%i"
132 msgstr "xyz%li"
133 # Valid: size is ignored
134 msgid  "abc%i"
135 msgstr "xyz%lli"
136 # Valid: size is ignored
137 msgid  "abc%i"
138 msgstr "xyz%Li"
139 # Valid: size is ignored
140 msgid  "abc%hhi"
141 msgstr "xyz%hi"
142 # Valid: size is ignored
143 msgid  "abc%hhi"
144 msgstr "xyz%li"
145 # Valid: size is ignored
146 msgid  "abc%hhi"
147 msgstr "xyz%lli"
148 # Valid: size is ignored
149 msgid  "abc%hhi"
150 msgstr "xyz%Li"
151 # Valid: size is ignored
152 msgid  "abc%hi"
153 msgstr "xyz%li"
154 # Valid: size is ignored
155 msgid  "abc%hi"
156 msgstr "xyz%lli"
157 # Valid: size is ignored
158 msgid  "abc%hi"
159 msgstr "xyz%Li"
160 # Valid: size is ignored
161 msgid  "abc%li"
162 msgstr "xyz%lli"
163 # Valid: size is ignored
164 msgid  "abc%li"
165 msgstr "xyz%Li"
166 # Invalid: type incompatibility for width
167 msgid  "abc%g%*g"
168 msgstr "xyz%*g%g"
169 EOF
170
171 : ${MSGFMT=msgfmt}
172 n=0
173 while read comment; do
174   read msgid_line
175   read msgstr_line
176   n=`expr $n + 1`
177   cat <<EOF > f-bo-2-$n.po
178 #, boost-format
179 ${msgid_line}
180 ${msgstr_line}
181 EOF
182   fail=
183   if echo "$comment" | grep 'Valid:' > /dev/null; then
184     if ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po; then
185       :
186     else
187       fail=yes
188     fi
189   else
190     ${MSGFMT} --check-format -o f-bo-2-$n.mo f-bo-2-$n.po 2> /dev/null
191     if test $? = 1; then
192       :
193     else
194       fail=yes
195     fi
196   fi
197   if test -n "$fail"; then
198     echo "Format string checking error:" 1>&2
199     cat f-bo-2-$n.po 1>&2
200     exit 1
201   fi
202   rm -f f-bo-2-$n.po f-bo-2-$n.mo
203 done < f-bo-2.data
204
205 exit 0