Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-pascal-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of Object Pascal format strings.
5
6 cat <<\EOF > f-op-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, with different widths
17 msgid  "abc%2sdef"
18 msgstr "xyz%3s"
19 # Valid: same arguments but in numbered syntax
20 msgid  "abc%s%gdef"
21 msgstr "xyz%0:s%1:g"
22 # Valid: permutation
23 msgid  "abc%s%g%cdef"
24 msgstr "xyz%2:c%1:g%0:s"
25 # Invalid: too few arguments
26 msgid  "abc%1:xdef%0:s"
27 msgstr "xyz%0:s"
28 # Invalid: too few arguments
29 msgid  "abc%sdef%x"
30 msgstr "xyz%s"
31 # Invalid: too many arguments
32 msgid  "abc%xdef"
33 msgstr "xyz%xvw%p"
34 # Valid: same numbered arguments, with different widths
35 msgid  "abc%1:5s%0:4s"
36 msgstr "xyz%1:4s%0:5s"
37 # Valid: same numbered arguments
38 msgid  "abc%:s"
39 msgstr "xyz%0:s"
40 # Valid: same numbered arguments
41 msgid  "abc%0:s"
42 msgstr "xyz%:s"
43 # Invalid: missing argument
44 msgid  "abc%1:sdef%0:x"
45 msgstr "xyz%0:x"
46 # Invalid: missing argument
47 msgid  "abc%0:sdef%1:x"
48 msgstr "xyz%1:x"
49 # Invalid: added argument
50 msgid  "abc%0:xdef"
51 msgstr "xyz%0:xvw%1:p"
52 # Valid: type compatibility
53 msgid  "abc%d"
54 msgstr "xyz%u"
55 # Valid: type compatibility
56 msgid  "abc%d"
57 msgstr "xyz%x"
58 # Valid: type compatibility
59 msgid  "abc%u"
60 msgstr "xyz%x"
61 # Valid: type compatibility
62 msgid  "abc%e"
63 msgstr "xyz%f"
64 # Valid: type compatibility
65 msgid  "abc%e"
66 msgstr "xyz%g"
67 # Valid: type compatibility
68 msgid  "abc%e"
69 msgstr "xyz%n"
70 # Valid: type compatibility
71 msgid  "abc%e"
72 msgstr "xyz%m"
73 # Invalid: type incompatibility
74 msgid  "abc%d"
75 msgstr "xyz%e"
76 # Invalid: type incompatibility
77 msgid  "abc%d"
78 msgstr "xyz%s"
79 # Invalid: type incompatibility
80 msgid  "abc%d"
81 msgstr "xyz%p"
82 # Invalid: type incompatibility
83 msgid  "abc%e"
84 msgstr "xyz%s"
85 # Invalid: type incompatibility
86 msgid  "abc%e"
87 msgstr "xyz%p"
88 # Invalid: type incompatibility
89 msgid  "abc%s"
90 msgstr "xyz%p"
91 # Invalid: type incompatibility for width
92 msgid  "abc%g%*g"
93 msgstr "xyz%*g%g"
94 EOF
95
96 : ${MSGFMT=msgfmt}
97 n=0
98 while read comment; do
99   read msgid_line
100   read msgstr_line
101   n=`expr $n + 1`
102   cat <<EOF > f-op-2-$n.po
103 #, object-pascal-format
104 ${msgid_line}
105 ${msgstr_line}
106 EOF
107   fail=
108   if echo "$comment" | grep 'Valid:' > /dev/null; then
109     if ${MSGFMT} --check-format -o f-op-2-$n.mo f-op-2-$n.po; then
110       :
111     else
112       fail=yes
113     fi
114   else
115     ${MSGFMT} --check-format -o f-op-2-$n.mo f-op-2-$n.po 2> /dev/null
116     if test $? = 1; then
117       :
118     else
119       fail=yes
120     fi
121   fi
122   if test -n "$fail"; then
123     echo "Format string checking error:" 1>&2
124     cat f-op-2-$n.po 1>&2
125     exit 1
126   fi
127   rm -f f-op-2-$n.po f-op-2-$n.mo
128 done < f-op-2.data
129
130 exit 0