]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
tests: Add test for C++11 string literals
authorDaiki Ueno <ueno@gnu.org>
Tue, 2 Dec 2014 06:12:57 +0000 (15:12 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 2 Dec 2014 08:14:46 +0000 (17:14 +0900)
* xgettext-c-20: New file.
* Makefile.am (TESTS): Add new test.

gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/xgettext-c-20 [new file with mode: 0755]

index 2d1dbe7cbef87e3b6eea0f444e0db6ae1bb23eeb..f8af86e97d68ff70193a2b7d2783addd18bbe8e0 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-02  Daiki Ueno  <ueno@gnu.org>
+
+       tests: Add test for C++11 string literals
+       * xgettext-c-20: New file.
+       * Makefile.am (TESTS): Add new test.
+
 2014-12-01  Daiki Ueno  <ueno@gnu.org>
 
        tests: Add more tests for C# Unicode handling
index f5766cc678a07dcc4e8c6fb0c3378e8efd3e41c4..db3365bfdf6ece2e97b67bf598dd3a90aae79339 100644 (file)
@@ -76,7 +76,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5 gettext-6 gettext-7 \
        xgettext-c-2 xgettext-c-3 xgettext-c-4 xgettext-c-5 \
        xgettext-c-6 xgettext-c-7 xgettext-c-8 xgettext-c-9 xgettext-c-10 \
        xgettext-c-11 xgettext-c-12 xgettext-c-13 xgettext-c-14 xgettext-c-15 \
-       xgettext-c-16 xgettext-c-17 xgettext-c-18 xgettext-c-19 \
+       xgettext-c-16 xgettext-c-17 xgettext-c-18 xgettext-c-19 xgettext-c-20 \
        xgettext-csharp-1 xgettext-csharp-2 xgettext-csharp-3 \
        xgettext-csharp-4 xgettext-csharp-5 xgettext-csharp-6 \
        xgettext-csharp-7 xgettext-csharp-8 \
diff --git a/gettext-tools/tests/xgettext-c-20 b/gettext-tools/tests/xgettext-c-20
new file mode 100755 (executable)
index 0000000..73e4442
--- /dev/null
@@ -0,0 +1,128 @@
+#! /bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Test C support: C++11 string literals.
+
+: ${XGETTEXT=xgettext}
+
+cat <<\EOF > err0.c
+gettext ("aaa(
+bbb
+)ccc");
+EOF
+
+(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err0.c 2>&1; exit) | grep 'unterminated string literal' || exit 1
+
+cat <<\EOF > err1.c
+gettext (R"aaa(
+bbb
+)ccc");
+EOF
+
+(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err1.c 2>&1; exit) | grep 'unterminated string literal' || exit 1
+
+cat <<\EOF > xg-c-20.cc
+#define X ""
+gettext (X"This is a concatenation of a macro and a string");
+
+gettext (u8"This is a UTF-8 string");
+
+u88"This is not a UTF-8 string";
+
+u"This is a UTF-16 string";
+
+U"This is a UTF-32 string";
+
+L"This is a wide string";
+
+gettext (R"aaa(
+This is a raw string
+)aaa");
+
+gettext (u8R"aaa(
+This is a raw UTF-8 string
+)aaa");
+
+uR"aaa(
+This is a UTF-16 raw string
+)aaa";
+
+LR"aaa(
+This is a wide raw string
+)aaa";
+
+// Missing opening parenthesis; be tolerate and treat it as a normal string.
+gettext (u8R"bar)
+aaa");
+
+// Missing closing parenthesis; be tolerate and treat it as a normal string.
+gettext (u8R"aaa(
+bar");
+
+// 'LR' prefixed raw string should be skipped.
+LR"(
+
+baz
+
+gettext(\"abc\");
+)";
+EOF
+
+${XGETTEXT} --add-comments --no-location --no-wrap \
+           -o - xg-c-20.cc | grep -v 'POT-Creation-Date' > xg-c-20.tmp.po \
+           || { cp core* ..; exit 1; }
+LC_ALL=C tr -d '\r' < xg-c-20.tmp.po > xg-c-20.po || exit 1
+
+cat <<\EOF > xg-c-20.ok
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "This is a concatenation of a macro and a string"
+msgstr ""
+
+msgid "This is a UTF-8 string"
+msgstr ""
+
+msgid ""
+"\n"
+"This is a raw string\n"
+msgstr ""
+
+msgid ""
+"\n"
+"This is a raw UTF-8 string\n"
+msgstr ""
+
+#. Missing opening parenthesis; be tolerate and treat it as a normal string.
+msgid ""
+"bar)\n"
+"aaa"
+msgstr ""
+
+#. Missing closing parenthesis; be tolerate and treat it as a normal string.
+msgid ""
+"aaa(\n"
+"bar"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-c-20.ok xg-c-20.po
+result=$?
+
+exit $result