--- /dev/null
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# Some tests for Rust support
+
+cat <<EOF > xg-rs-1.rs
+use gettext_rs::gettext;
+
+pub trait TestCase {
+ fn TestCase() {
+ GettextResourceManager rm = new GettextResourceManager("test");
+ // standard usage
+ String test1 = gettext("Test String 1");
+ /* C style comment */
+ String test2 = gettext("Test String 2");
+ // "multiline" string
+ String test3 = gettext("Test " +
+ "String " +
+ "3");
+ // macro
+ String test2 = gettext!("Test String 4");
+ // empty string
+ String test4 = gettext("");
+ // byte string
+ String test2 = gettext(b"Test String 5");
+ // raw string
+ String test5 = gettext(r#"first line
+second line
+third line"#);
+ }
+}
+EOF
+
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header --no-location -c -d xg-rs-1.tmp xg-rs-1.rs || Exit 1
+LC_ALL=C tr -d '\r' < xg-rs-1.tmp.po > xg-rs-1.po || Exit 1
+
+cat <<EOF > xg-rs-1.ok
+#. standard usage
+msgid "Test String 1"
+msgstr ""
+
+#. C style comment
+msgid "Test String 2"
+msgstr ""
+
+#. "multiline" string
+msgid "Test String 3"
+msgstr ""
+
+#. macro
+msgid "Test String 4"
+msgstr ""
+
+#. empty string
+msgid ""
+msgstr ""
+
+#. byte string
+msgid "Test String 5"
+msgstr ""
+
+#. raw string
+msgid ""
+"first line\n"
+"second line\n"
+"third line"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-rs-1.ok xg-rs-1.po
+result=$?
+
+exit $result
--- /dev/null
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# More tests for Rust support: UTF-8 characters
+
+cat <<\EOF > xg-rs-2.rs
+pub trait TestCase {
+ fn main () {
+ catalog.gettext("Russian (Русский): Здравствуйте"));
+ catalog.gettext("Vietnamese (Tiếng Việt): Chào bạn"));
+ catalog.gettext("Japanese (日本語): こんにちは"));
+ catalog.gettext("Thai (ภาษาไทย): สวัสดีครับ"));
+ catalog.gettext("Script: 𝒞"));
+ catalog.gettext("Russian (\u{0420}\u{0443}\u{0441}\u{0441}\u{043a}\u{0438}\u{0439}): \u{0417}\u{0434}\u{0440}\u{0430}\u{0432}\u{0441}\u{0442}\u{0432}\u{0443}\u{0439}\u{0442}\u{0435}"));
+ catalog.gettext("Vietnamese (Ti\u{1ebf}ng Vi\u{1ec7}t): Ch\u{00e0}o b\u{1ea1}n"));
+ catalog.gettext("Japanese (\u{65e5}\u{672c}\u{8a9e}): \u{3053}\u{3093}\u{306b}\u{3061}\u{306f}"));
+ catalog.gettext("Thai (\u{0e20}\u{0e32}\u{0e29}\u{0e32}\u{0e44}\u{0e17}\u{0e22}): \u{0e2a}\u{0e27}\u{0e31}\u{0e2a}\u{0e14}\u{0e35}\u{0e04}\u{0e23}\u{0e31}\u{0e1a}"));
+ catalog.gettext("Script: \u{1d49e}"));
+ // And now a comment with Русский and 日本語 and Unicode escapes: B\u{00f6}se B\u{00fc}bchen
+ catalog.gettext("This string has a multilingual comment"));
+ // Unicode identifiers.
+ String あ = "";
+ String 𐀀 = "";
+ }
+}
+EOF
+
+: ${XGETTEXT=xgettext}
+# delete POT-Creation-Date: line because the date depends on local time.
+${XGETTEXT} --output xg-rs-2.tmp --add-location -c xg-rs-2.rs || Exit 1
+sed -e '/\"POT-Creation-Date:.*/d' < xg-rs-2.tmp | LC_ALL=C tr -d '\r' > xg-rs-2.po || Exit 1
+
+cat <<\EOF > xg-rs-2.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=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: xg-rs-2.rs:3 xg-rs-2.rs:8
+msgid "Russian (Русский): Здравствуйте"
+msgstr ""
+
+#: xg-rs-2.rs:4 xg-rs-2.rs:9
+msgid "Vietnamese (Tiếng Việt): Chào bạn"
+msgstr ""
+
+#: xg-rs-2.rs:5 xg-rs-2.rs:10
+msgid "Japanese (日本語): こんにちは"
+msgstr ""
+
+#: xg-rs-2.rs:6 xg-rs-2.rs:11
+msgid "Thai (ภาษาไทย): สวัสดีครับ"
+msgstr ""
+
+#: xg-rs-2.rs:7 xg-rs-2.rs:12
+msgid "Script: 𝒞"
+msgstr ""
+
+#. And now a comment with Русский and 日本語 and Unicode escapes: B\u{00f6}se B\u{00fc}bchen
+#: xg-rs-2.rs:14
+msgid "This string has a multilingual comment"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-rs-2.ok xg-rs-2.po
+result=$?
+
+exit $result
--- /dev/null
+#!/bin/sh
+. "${srcdir=.}/init.sh"; path_prepend_ . ../src
+
+# More tests for Rust support: string syntax
+
+LC_ALL=C tr '%' '\015' <<\EOF > xg-rs-3.rs
+pub trait TestCase {
+ fn main () {
+ // Test recognition of \u escapes.
+ gettext("B\u{00f6}se B\u{00fc}bchen");
+ // \u escapes with more than one u are invalid.
+ gettext("Japanese: \uu{6585}\uuu{6723}\u{8A9e}");
+ gettext("embedded\nnewline");
+ // Two backslashes (unlike in Java, where this is just one backslash).
+ gettext("\u{005c}\u{005c}");
+ // A 6-character string (unlike in Java, where this is just one backslash).
+ gettext("\\u005c");
+ // A single backslash.
+ gettext("\\");
+ // Escape sequences in strings.
+ gettext("t -> \t, n -> \n, dquote -> \", squote -> \' ...");
+ // Hex escapes are recognized.
+ gettext("bel: \x07\n");
+ gettext // Recognized despite comments
+ ( /* Even across multiline
+comment! */ "this is a single " /* now comes the concatenation! */ + // after +
+ "long line");
+ // Byte string literals are extracted.
+ gettext(b"byte 1");
+ // In byte string literals, escape sequences are recognized.
+ gettext(b"byte 2 \u{005c} \\ \t \n");
+ // Raw string literals are extracted.
+ gettext(r"raw 1");
+ // In raw string literals, no escape sequences are recognized.
+ gettext(r"raw 2 \u{005c} \\ \t \n \'");
+ // In raw string literals, only delimiters without the proper number of
+ // hashes are recognized.
+ gettext (r##"raw 3 ""test"##);
+ // Normal and raw string literals can be concatenated.
+ gettext("left - \"quot" + r#"ation"" - right"#);
+ // Character literals are not extracted.
+ gettext('x');
+ // Invalid concatenations are not concatenated.
+ gettext("fooba"+'r');
+ }
+}
+EOF
+
+: ${XGETTEXT=xgettext}
+# delete POT-Creation-Date: line because the date depends on local time.
+${XGETTEXT} --output xg-rs-3.tmp --add-location -c -kmygettext:2 xg-rs-3.rs 2>/dev/null || Exit 1
+sed -e '/\"POT-Creation-Date:.*/d' < xg-rs-3.tmp | LC_ALL=C tr -d '\r' > xg-rs-3.po || Exit 1
+
+cat <<\EOF > xg-rs-3.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=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Test recognition of \u escapes.
+#: xg-rs-3.rs:4
+msgid "Böse Bübchen"
+msgstr ""
+
+#. \u escapes with more than one u are invalid.
+#: xg-rs-3.rs:6
+#, rust-format
+msgid "Japanese: \\uu{6585}\\uuu{6723}語"
+msgstr ""
+
+#: xg-rs-3.rs:7
+msgid ""
+"embedded\n"
+"newline"
+msgstr ""
+
+#. Two backslashes (unlike in Java, where this is just one backslash).
+#: xg-rs-3.rs:9
+msgid "\\\\"
+msgstr ""
+
+#. A 6-character string (unlike in Java, where this is just one backslash).
+#: xg-rs-3.rs:11
+msgid "\\u005c"
+msgstr ""
+
+#. A single backslash.
+#: xg-rs-3.rs:13
+msgid "\\"
+msgstr ""
+
+#. Escape sequences in strings.
+#: xg-rs-3.rs:15
+msgid ""
+"t -> \t, n -> \n"
+", dquote -> \", squote -> ' ..."
+msgstr ""
+
+#. Hex escapes are recognized.
+#: xg-rs-3.rs:17
+msgid "bel: \a\n"
+msgstr ""
+
+#. Recognized despite comments
+#. Even across multiline
+#. comment!
+#: xg-rs-3.rs:20
+msgid "this is a single long line"
+msgstr ""
+
+#. Byte string literals are extracted.
+#: xg-rs-3.rs:23
+msgid "byte 1"
+msgstr ""
+
+#. In byte string literals, escape sequences are recognized.
+#: xg-rs-3.rs:25
+msgid "byte 2 \\ \\ \t \n"
+msgstr ""
+
+#. Raw string literals are extracted.
+#: xg-rs-3.rs:27
+msgid "raw 1"
+msgstr ""
+
+#. In raw string literals, no escape sequences are recognized.
+#: xg-rs-3.rs:29
+msgid "raw 2 \\u{005c} \\\\ \\t \\n \\'"
+msgstr ""
+
+#. In raw string literals, only delimiters without the proper number of
+#. hashes are recognized.
+#: xg-rs-3.rs:32
+msgid "raw 3 \"test"
+msgstr ""
+
+#. Normal and raw string literals can be concatenated.
+#: xg-rs-3.rs:34
+msgid "left - \"quotation\" - right"
+msgstr ""
+
+#. Invalid concatenations are not concatenated.
+#: xg-rs-3.rs:38
+msgid "fooba"
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-rs-3.ok xg-rs-3.po
+result=$?
+
+exit $result