Add selftest coverage for %{ and %} in pretty-print.cc

No functional change intended.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r15-3197-g276cc4324b9e8d.

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 <dmalc...@redhat.com>
---
 gcc/pretty-print.cc | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc
index 64713803dbe7..1d91da828212 100644
--- a/gcc/pretty-print.cc
+++ b/gcc/pretty-print.cc
@@ -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 ();
-- 
2.26.3

Reply via email to