Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-csharp-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of Java format strings.
5
6 cat <<\EOF > f-cs-2.data
7 # Invalid: invalid msgstr
8 msgid  "abc{0}def"
9 msgstr "abc{"
10 # Valid: same arguments
11 msgid  "abc{1}def"
12 msgstr "xyz{1}"
13 # Valid: same arguments, differently written
14 msgid  "abc{1}def"
15 msgstr "xyz{01}"
16 # Valid: permutation
17 msgid  "abc{2}{0}{1}def"
18 msgstr "xyz{1}{0}{2}"
19 # Invalid: too few arguments
20 msgid  "abc{1}def{0}"
21 msgstr "xyz{0}"
22 # Invalid: too many arguments
23 msgid  "abc{0}def"
24 msgstr "xyz{0}uvw{1}"
25 # Valid: missing non-final argument
26 msgid  "abc{1}def{0}"
27 msgstr "xyz{1}"
28 # Valid: added non-final argument
29 msgid  "abc{1}def"
30 msgstr "xyz{0}{1}"
31 # Invalid: different number of arguments
32 msgid  "abc{500000000}def"
33 msgstr "xyz{500000001}"
34 # Valid: type compatibility
35 msgid  "abc{1:X}"
36 msgstr "xyz{1:g}"
37 EOF
38
39 : ${MSGFMT=msgfmt}
40 n=0
41 while read comment; do
42   read msgid_line
43   read msgstr_line
44   n=`expr $n + 1`
45   cat <<EOF > f-cs-2-$n.po
46 #, csharp-format
47 ${msgid_line}
48 ${msgstr_line}
49 EOF
50   fail=
51   if echo "$comment" | grep 'Valid:' > /dev/null; then
52     if ${MSGFMT} --check-format -o f-cs-2-$n.mo f-cs-2-$n.po; then
53       :
54     else
55       fail=yes
56     fi
57   else
58     ${MSGFMT} --check-format -o f-cs-2-$n.mo f-cs-2-$n.po 2> /dev/null
59     if test $? = 1; then
60       :
61     else
62       fail=yes
63     fi
64   fi
65   if test -n "$fail"; then
66     echo "Format string checking error:" 1>&2
67     cat f-cs-2-$n.po 1>&2
68     exit 1
69   fi
70   rm -f f-cs-2-$n.po f-cs-2-$n.mo
71 done < f-cs-2.data
72
73 exit 0