]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Test boost-format recognition.
authorBruno Haible <bruno@clisp.org>
Mon, 13 Feb 2006 13:12:35 +0000 (13:12 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:13:00 +0000 (12:13 +0200)
gettext-tools/tests/xgettext-c-14 [new file with mode: 0755]

diff --git a/gettext-tools/tests/xgettext-c-14 b/gettext-tools/tests/xgettext-c-14
new file mode 100755 (executable)
index 0000000..05ad5fd
--- /dev/null
@@ -0,0 +1,72 @@
+#! /bin/sh
+
+# Test C++ support: test boost-format.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles xg-c-14.cc"
+cat <<\EOF > xg-c-14.cc
+// These are recognized as boost-format because of the keyword 'format'.
+format(gettext("%s on, %s off"));
+format(gettext("%1$d on, %2$d off"));
+format(gettext("%|1$| on, %|2$| off"));
+format(gettext("%1% on, %2% off"));
+// These are recognized as boost-format only through the heuristics.
+gettext("heuristic %s on, %s off");
+gettext("heuristic %1$d on, %2$d off");
+gettext("heuristic %|1$| on, %|2$| off");
+gettext("heuristic %1% on, %2% off");
+EOF
+
+tmpfiles="$tmpfiles xg-c-14.po"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -d xg-c-14 --boost xg-c-14.cc
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+# The first 4 are not marked as c-format, because they are known as
+# boost-format. The last 4 are governed by the heuristic. The first two
+# among them are valid c-format strings. The last one is a valid but unlikely
+# c-format string, therefore the heuristic doesn't mark it.
+tmpfiles="$tmpfiles xg-c-14.ok"
+cat <<\EOF > xg-c-14.ok
+#, boost-format
+msgid "%s on, %s off"
+msgstr ""
+
+#, boost-format
+msgid "%1$d on, %2$d off"
+msgstr ""
+
+#, boost-format
+msgid "%|1$| on, %|2$| off"
+msgstr ""
+
+#, boost-format
+msgid "%1% on, %2% off"
+msgstr ""
+
+#, c-format, boost-format
+msgid "heuristic %s on, %s off"
+msgstr ""
+
+#, c-format, boost-format
+msgid "heuristic %1$d on, %2$d off"
+msgstr ""
+
+#, boost-format
+msgid "heuristic %|1$| on, %|2$| off"
+msgstr ""
+
+#, boost-format
+msgid "heuristic %1% on, %2% off"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-c-14.ok xg-c-14.po
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result