Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-c-14
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test C++ support: test boost-format.
5
6 cat <<\EOF > xg-c-14.cc
7 // These are recognized as boost-format because of the keyword 'format'.
8 format(gettext("%s on, %s off"));
9 format(gettext("%1$d on, %2$d off"));
10 format(gettext("%|1$| on, %|2$| off"));
11 format(gettext("%1% on, %2% off"));
12 // These are recognized as boost-format only through the heuristics.
13 gettext("heuristic %s on, %s off");
14 gettext("heuristic %1$d on, %2$d off");
15 gettext("heuristic %|1$| on, %|2$| off");
16 gettext("heuristic %1% on, %2% off");
17 EOF
18
19 : ${XGETTEXT=xgettext}
20 ${XGETTEXT} --omit-header --no-location -d xg-c-14.tmp --boost xg-c-14.cc || exit 1
21 LC_ALL=C tr -d '\r' < xg-c-14.tmp.po > xg-c-14.po || exit 1
22
23 # The first 4 are not marked as c-format, because they are known as
24 # boost-format. The last 4 are governed by the heuristic. The first two
25 # among them are valid c-format strings. The last one is a valid but unlikely
26 # c-format string, therefore the heuristic doesn't mark it.
27 cat <<\EOF > xg-c-14.ok
28 #, boost-format
29 msgid "%s on, %s off"
30 msgstr ""
31
32 #, boost-format
33 msgid "%1$d on, %2$d off"
34 msgstr ""
35
36 #, boost-format
37 msgid "%|1$| on, %|2$| off"
38 msgstr ""
39
40 #, boost-format
41 msgid "%1% on, %2% off"
42 msgstr ""
43
44 #, c-format, boost-format
45 msgid "heuristic %s on, %s off"
46 msgstr ""
47
48 #, c-format, boost-format
49 msgid "heuristic %1$d on, %2$d off"
50 msgstr ""
51
52 #, boost-format
53 msgid "heuristic %|1$| on, %|2$| off"
54 msgstr ""
55
56 #, boost-format
57 msgid "heuristic %1% on, %2% off"
58 msgstr ""
59 EOF
60
61 : ${DIFF=diff}
62 ${DIFF} xg-c-14.ok xg-c-14.po
63 result=$?
64
65 exit $result