]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Objective-C: xgettext: Strengthen tests.
authorBruno Haible <bruno@clisp.org>
Thu, 27 Mar 2025 18:09:57 +0000 (19:09 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 27 Mar 2025 18:09:57 +0000 (19:09 +0100)
* gettext-tools/tests/xgettext-objc-1: Add test cases with format strings.

gettext-tools/tests/xgettext-objc-1

index 9d34c136f08fa14cd48f1279c4dcf1f53ee3498e..b91f00d662a9727cf60643b2216b758d131a220c 100755 (executable)
@@ -23,6 +23,26 @@ _ // test
 )
 
 NSLocalizedString(@"Information", @"")
+
+// This is a C format string.
+printf (gettext ("foo %s"));
+
+// This is an Objective-C format string without Objective-C extensions.
+// Therefore it's OK to label it as a C format string.
+stringWithFormat (gettext ("bar %s"));
+
+// It is unknown whether this is used as a C format string or as an Objective-C
+// format string. But in any case, it does not have Objective-C extensions.
+// Therefore it's OK to label it as a C format string.
+gettext ("baz %s");
+
+// This is an Objective-C format string with Objective-C extensions.
+stringWithFormat (gettext ("objcbar %@"));
+
+// This is a format string with Objective-C extensions. It cannot be used as a
+// C format string. Therefore it is better to label it as an Objective-C format
+// string.
+gettext ("objcbaz %@");
 EOF
 
 : ${XGETTEXT=xgettext}
@@ -49,6 +69,31 @@ msgstr ""
 #: xg-ob-1.m:19
 msgid "Information"
 msgstr ""
+
+#: xg-ob-1.m:22
+#, c-format
+msgid "foo %s"
+msgstr ""
+
+#: xg-ob-1.m:26
+#, c-format
+msgid "bar %s"
+msgstr ""
+
+#: xg-ob-1.m:31
+#, c-format
+msgid "baz %s"
+msgstr ""
+
+#: xg-ob-1.m:34
+#, objc-format
+msgid "objcbar %@"
+msgstr ""
+
+#: xg-ob-1.m:39
+#, objc-format
+msgid "objcbaz %@"
+msgstr ""
 EOF
 
 : ${DIFF=diff}