From: David Malcolm Date: Mon, 26 Aug 2024 16:24:21 +0000 (-0400) Subject: pretty-print: fixes to selftests X-Git-Tag: basepoints/gcc-16~6356 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=276cc4324b9e8d97fb1018d7b78cc0ed7e77f902;p=thirdparty%2Fgcc.git pretty-print: fixes to selftests 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 --- diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index 64713803dbe..1d91da82821 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 ();