diff options
author | David Malcolm <dmalcolm@redhat.com> | 2024-01-10 08:33:47 -0500 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2024-01-10 08:33:47 -0500 |
commit | 7daa935c7997f3d09536d6aeab91bff2b68ca297 (patch) | |
tree | 27581c9c23d390bb4b979f67a312cbd918485172 /gcc | |
parent | 6a3700f9b3ecbd4873964757812ebcb2ed51b008 (diff) | |
download | gcc-7daa935c7997f3d09536d6aeab91bff2b68ca297.zip gcc-7daa935c7997f3d09536d6aeab91bff2b68ca297.tar.gz gcc-7daa935c7997f3d09536d6aeab91bff2b68ca297.tar.bz2 |
pretty-print: add selftest coverage for numbered args
No functional change intended.
gcc/ChangeLog:
* pretty-print.cc (selftest::test_pp_format): Add selftest
coverage for numbered args.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/pretty-print.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc index fd4c38e..859ae2a 100644 --- a/gcc/pretty-print.cc +++ b/gcc/pretty-print.cc @@ -2605,6 +2605,20 @@ test_pp_format () assert_pp_format (SELFTEST_LOCATION, "item 3 of 7", "item %i of %i", 3, 7); assert_pp_format (SELFTEST_LOCATION, "problem with `bar' at line 10", "problem with %qs at line %i", "bar", 10); + + /* Verified numbered args. */ + assert_pp_format (SELFTEST_LOCATION, + "foo: second bar: first", + "foo: %2$s bar: %1$s", + "first", "second"); + assert_pp_format (SELFTEST_LOCATION, + "foo: 1066 bar: 1776", + "foo: %2$i bar: %1$i", + 1776, 1066); + assert_pp_format (SELFTEST_LOCATION, + "foo: second bar: 1776", + "foo: %2$s bar: %1$i", + 1776, "second"); } /* A subclass of pretty_printer for use by test_prefixes_and_wrapping. */ |