diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-08-26 12:24:21 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-08-26 12:24:21 -0400 |
commit | 276cc4324b9e8d97fb1018d7b78cc0ed7e77f902 (patch) | |
tree | 20823d821d87b5823e0663e650949b5137e26458 /gcc | |
parent | b835710328847a8b1bc0c1258dd4a6d059988f79 (diff) | |
download | gcc-276cc4324b9e8d97fb1018d7b78cc0ed7e77f902.zip gcc-276cc4324b9e8d97fb1018d7b78cc0ed7e77f902.tar.gz gcc-276cc4324b9e8d97fb1018d7b78cc0ed7e77f902.tar.bz2 |
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 <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/pretty-print.cc | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index 6471380..1d91da8 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 (); |