]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pretty-print: fixes to selftests
authorDavid Malcolm <dmalcolm@redhat.com>
Mon, 26 Aug 2024 16:24:21 +0000 (12:24 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 26 Aug 2024 16:24:21 +0000 (12:24 -0400)
Add selftest coverage for %{ and %} in pretty-print.cc

No functional change intended.

gcc/ChangeLog:
* pretty-print.cc (selftest::test_urls): Make static.
(selftest::test_urls_from_braces): New.
(selftest::test_null_urls): Make static.
(selftest::test_urlification): Likewise.
(selftest::pretty_print_cc_tests): Call test_urls_from_braces.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/pretty-print.cc

index 64713803dbe7845a393e55332432c7bb1917ca2e..1d91da8282127b83765436e0ffbf09ce83a68f85 100644 (file)
@@ -3135,7 +3135,7 @@ test_prefixes_and_wrapping ()
 
 /* Verify that URL-printing works as expected.  */
 
-void
+static void
 test_urls ()
 {
   {
@@ -3169,9 +3169,40 @@ test_urls ()
   }
 }
 
+static void
+test_urls_from_braces ()
+{
+  {
+    pretty_printer pp;
+    pp.set_url_format (URL_FORMAT_NONE);
+    pp_printf (&pp, "before %{text%} after",
+                   "http://example.com");
+    ASSERT_STREQ ("before text after",
+                 pp_formatted_text (&pp));
+  }
+
+  {
+    pretty_printer pp;
+    pp.set_url_format (URL_FORMAT_ST);
+    pp_printf (&pp, "before %{text%} after",
+                   "http://example.com");
+    ASSERT_STREQ ("before \33]8;;http://example.com\33\\text\33]8;;\33\\ after",
+                 pp_formatted_text (&pp));
+  }
+
+  {
+    pretty_printer pp;
+    pp.set_url_format (URL_FORMAT_BEL);
+    pp_printf (&pp, "before %{text%} after",
+                   "http://example.com");
+    ASSERT_STREQ ("before \33]8;;http://example.com\atext\33]8;;\a after",
+                 pp_formatted_text (&pp));
+  }
+}
+
 /* Verify that we gracefully reject null URLs.  */
 
-void
+static void
 test_null_urls ()
 {
   {
@@ -3221,8 +3252,7 @@ pp_printf_with_urlifier (pretty_printer *pp,
   va_end (ap);
 }
 
-
-void
+static void
 test_urlification ()
 {
   class test_urlifier : public urlifier
@@ -3424,6 +3454,7 @@ pretty_print_cc_tests ()
   test_pp_format ();
   test_prefixes_and_wrapping ();
   test_urls ();
+  test_urls_from_braces ();
   test_null_urls ();
   test_urlification ();
   test_utf8 ();