From: Daiki Ueno Date: Wed, 8 Oct 2014 03:00:51 +0000 (+0900) Subject: tests: Improve test coverage of C and Vala scanners X-Git-Tag: v0.19.3~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa8e859254eac21d8742b47a55b31f67c267a6c8;p=thirdparty%2Fgettext.git tests: Improve test coverage of C and Vala scanners * xgettext-c-4: Check more trigraphs. * xgettext-c-2: Check floating point literal. * xgettext-c-19: Check out-of-range Unicode character, "\U" character escape, incomplete "\u" escape, and surrogates. * xgettext-vala-1: Check unterminated regexp literal, floating point literal, string template, "/=" operator, multi-line comments, and backslash-escaped character inside regexp literal. --- diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 22c1a374f..22fdc63c0 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,14 @@ +2014-10-08 Daiki Ueno + + tests: Improve test coverage of C and Vala scanners + * xgettext-c-4: Check more trigraphs. + * xgettext-c-2: Check floating point literal. + * xgettext-c-19: Check out-of-range Unicode character, "\U" + character escape, incomplete "\u" escape, and surrogates. + * xgettext-vala-1: Check unterminated regexp literal, floating + point literal, string template, "/=" operator, multi-line + comments, and backslash-escaped character inside regexp literal. + 2014-10-03 Daiki Ueno * lang-c++: Check if CXX is "no", not ":". See commit e854d2c7 diff --git a/gettext-tools/tests/xgettext-c-19 b/gettext-tools/tests/xgettext-c-19 index 06de17d6b..09a227a70 100755 --- a/gettext-tools/tests/xgettext-c-19 +++ b/gettext-tools/tests/xgettext-c-19 @@ -4,6 +4,15 @@ # Test C support: mixing ANSI escapes, Unicode escapes, and bare # multibyte characters. +: ${XGETTEXT=xgettext} + +cat <<\EOF > err1.c +/* Out of range */ +gettext ("\U00110000"); +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err1.c 2>&1; exit) | grep 'invalid Unicode character' || exit 1 + cat <<\EOF > xg-c-19.in.c /* 最初のコメント */ "最初の文字列"; @@ -12,20 +21,22 @@ cat <<\EOF > xg-c-19.in.c gettext ("二番目の文字列"); /* 三番目のコメント */ -pgettext ("\u30B3\u30F3\u30C6\u30AF\u30B9\u30C8", "\xBB\xB0\xC8\xD6\xCC\xDC\xA4\xCE\xCA\xB8\xBB\xFA\xCE\363"); +pgettext ("\u30B3\u30F3\u30C6\u30af\u30B9\u30C8\U0001F600\ud835\udc9ea", "\xBB\xB0\xC8\xD6\xCC\xDC\xA4\xCE\xCA\xB8\xBB\xFA\xCe\363"); + +gettext ("\"\'\?\\\a\b\f\n\r\t\v\xG\0000"); +gettext ("\u30A"); EOF : ${ICONV=iconv} iconv -f UTF-8 -t EUC-JP < xg-c-19.in.c > xg-c-19.c \ || { echo "Skipping test: iconv does not work for EUC-JP"; exit 77; } -: ${XGETTEXT=xgettext} -${XGETTEXT} --from-code=EUC-JP --add-comments --no-location \ +${XGETTEXT} --from-code=EUC-JP --add-comments --no-location --no-wrap \ -o - xg-c-19.c | grep -v 'POT-Creation-Date' > xg-c-19.tmp.po \ - || exit 1 + || { cp core* ..; exit 1; } LC_ALL=C tr -d '\r' < xg-c-19.tmp.po > xg-c-19.po || exit 1 -cat < xg-c-19.ok +cat <<\EOF > xg-c-19.ok # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. @@ -49,9 +60,17 @@ msgid "二番目の文字列" msgstr "" #. 三番目のコメント -msgctxt "コンテクスト" +msgctxt "コンテクスト😀𝒞a" msgid "三番目の文字列" msgstr "" + +msgid "" +"\"'?\\\a\b\f\n" +"\r\t\v\\xG" +msgstr "" + +msgid "\\u30A" +msgstr "" EOF : ${DIFF=diff} diff --git a/gettext-tools/tests/xgettext-c-2 b/gettext-tools/tests/xgettext-c-2 index 550de6c59..0c53be80c 100755 --- a/gettext-tools/tests/xgettext-c-2 +++ b/gettext-tools/tests/xgettext-c-2 @@ -19,6 +19,8 @@ static int c = ''; _("after character") static char *s = ""; _("after string") +static double d = 10e-1; +_("after double") EOF : ${XGETTEXT=xgettext} @@ -41,6 +43,9 @@ msgstr "" msgid "after string" msgstr "" + +msgid "after double" +msgstr "" EOF : ${DIFF=diff} diff --git a/gettext-tools/tests/xgettext-c-4 b/gettext-tools/tests/xgettext-c-4 index e8f161a4b..7db3e35ac 100755 --- a/gettext-tools/tests/xgettext-c-4 +++ b/gettext-tools/tests/xgettext-c-4 @@ -4,7 +4,7 @@ # Test C support: --trigraphs option. cat < xg-c-4.in.c -main()?? +main()?? EOF : ${XGETTEXT=xgettext} diff --git a/gettext-tools/tests/xgettext-vala-1 b/gettext-tools/tests/xgettext-vala-1 index 7eda7be00..9d87381f1 100755 --- a/gettext-tools/tests/xgettext-vala-1 +++ b/gettext-tools/tests/xgettext-vala-1 @@ -3,6 +3,15 @@ # Test of Vala support. +: ${XGETTEXT=xgettext} + +cat <<\EOF > xg-vala-1.err.vala +int main (string[] args) { + var r1 = /a +EOF + +(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location -o - xg-vala-1.err.vala 2>&1; exit) | grep 'regular expression literal terminated too early' || exit 1 + cat <<\EOF > xg-vala-1.vala int main (string[] args) { var s1 = "Simple string, " + " no gettext needed"; @@ -23,14 +32,25 @@ int main (string[] args) { var s5 = _("Extract this \u2464th string"); - var s6 = /_("This is a regex literal and must not be extracted!")/i; + var s6 = /_("This is a regex literal and must not be extracted!")\|/i; + var d1 = 10e-1; + var d2 = 10E-1; + + /* This is a + multiline C style comment */ var s7 = _("Extract this //sixth string"); + + var s8 = _(@"This is a template string, which cannot be extracted!"); + + /* /= shouldn't start a regex literal */ + var i1 = 1000; + i1 /= 10; + return 0; } EOF -: ${XGETTEXT=xgettext} ${XGETTEXT} --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err test $? = 0 || { cat xg-vala-1.err; exit 1; } # Don't simplify this to "grep ... < xg-vala-1.tmp", otherwise OpenBSD 4.0 grep @@ -75,6 +95,8 @@ msgstr "" msgid "Extract this ⑤th string" msgstr "" +#. This is a +#. multiline C style comment msgid "Extract this //sixth string" msgstr "" EOF @@ -138,6 +160,8 @@ msgstr "" msgid "Extract this ⑤th string" msgstr "" +#. This is a +#. multiline C style comment msgid "Extract this //sixth string" msgstr "" EOF