@@ -20,7 +20,7 @@ inline void PassFmt(util::ConstevalFormatString<NumArgs> fmt)
2020 decltype (fmt)::Detail_CheckNumFormatSpecifiers (fmt.fmt );
2121}
2222template <unsigned WrongNumArgs>
23- inline void FailFmtWithError (std::string_view wrong_fmt, std::string_view error)
23+ inline void FailFmtWithError (const char * wrong_fmt, std::string_view error)
2424{
2525 BOOST_CHECK_EXCEPTION (util::ConstevalFormatString<WrongNumArgs>::Detail_CheckNumFormatSpecifiers (wrong_fmt), const char *, HasReason (error));
2626}
@@ -44,6 +44,8 @@ BOOST_AUTO_TEST_CASE(ConstevalFormatString_NumSpec)
4444 PassFmt<1 >(" %+2s" );
4545 PassFmt<1 >(" %.6i" );
4646 PassFmt<1 >(" %5.2f" );
47+ PassFmt<1 >(" %5.f" );
48+ PassFmt<1 >(" %.f" );
4749 PassFmt<1 >(" %#x" );
4850 PassFmt<1 >(" %1$5i" );
4951 PassFmt<1 >(" %1$-5i" );
@@ -54,32 +56,60 @@ BOOST_AUTO_TEST_CASE(ConstevalFormatString_NumSpec)
5456 PassFmt<1 >(" %_" );
5557 PassFmt<1 >(" %\n " );
5658
57- // The `*` specifier behavior is unsupported and can lead to runtime
58- // errors when used in a ConstevalFormatString. Please refer to the
59- // note in the ConstevalFormatString docs.
60- PassFmt<1 >(" %*c" );
61- PassFmt<2 >(" %2$*3$d" );
62- PassFmt<1 >(" %.*f" );
59+ PassFmt<2 >(" %*c" );
60+ PassFmt<2 >(" %+*c" );
61+ PassFmt<2 >(" %.*f" );
62+ PassFmt<3 >(" %*.*f" );
63+ PassFmt<3 >(" %2$*3$d" );
64+ PassFmt<3 >(" %2$*3$.9d" );
65+ PassFmt<3 >(" %2$.*3$d" );
66+ PassFmt<3 >(" %2$9.*3$d" );
67+ PassFmt<3 >(" %2$+9.*3$d" );
68+ PassFmt<4 >(" %3$*2$.*4$f" );
69+
70+ // Make sure multiple flag characters "- 0+" are accepted
71+ PassFmt<3 >(" '%- 0+*.*f'" );
72+ PassFmt<3 >(" '%1$- 0+*3$.*2$f'" );
6373
6474 auto err_mix{" Format specifiers must be all positional or all non-positional!" };
6575 FailFmtWithError<1 >(" %s%1$s" , err_mix);
76+ FailFmtWithError<2 >(" %2$*d" , err_mix);
77+ FailFmtWithError<2 >(" %*2$d" , err_mix);
78+ FailFmtWithError<2 >(" %.*3$d" , err_mix);
79+ FailFmtWithError<2 >(" %2$.*d" , err_mix);
6680
6781 auto err_num{" Format specifier count must match the argument count!" };
6882 FailFmtWithError<1 >(" " , err_num);
6983 FailFmtWithError<0 >(" %s" , err_num);
7084 FailFmtWithError<2 >(" %s" , err_num);
7185 FailFmtWithError<0 >(" %1$s" , err_num);
7286 FailFmtWithError<2 >(" %1$s" , err_num);
87+ FailFmtWithError<1 >(" %*c" , err_num);
7388
7489 auto err_0_pos{" Positional format specifier must have position of at least 1" };
7590 FailFmtWithError<1 >(" %$s" , err_0_pos);
7691 FailFmtWithError<1 >(" %$" , err_0_pos);
7792 FailFmtWithError<0 >(" %0$" , err_0_pos);
7893 FailFmtWithError<0 >(" %0$s" , err_0_pos);
94+ FailFmtWithError<2 >(" %2$*$d" , err_0_pos);
95+ FailFmtWithError<2 >(" %2$*0$d" , err_0_pos);
96+ FailFmtWithError<3 >(" %3$*2$.*$f" , err_0_pos);
97+ FailFmtWithError<3 >(" %3$*2$.*0$f" , err_0_pos);
7998
8099 auto err_term{" Format specifier incorrectly terminated by end of string" };
81100 FailFmtWithError<1 >(" %" , err_term);
101+ FailFmtWithError<1 >(" %9" , err_term);
102+ FailFmtWithError<1 >(" %9." , err_term);
103+ FailFmtWithError<1 >(" %9.9" , err_term);
104+ FailFmtWithError<1 >(" %*" , err_term);
105+ FailFmtWithError<1 >(" %+*" , err_term);
106+ FailFmtWithError<1 >(" %.*" , err_term);
107+ FailFmtWithError<1 >(" %9.*" , err_term);
82108 FailFmtWithError<1 >(" %1$" , err_term);
109+ FailFmtWithError<1 >(" %1$9" , err_term);
110+ FailFmtWithError<2 >(" %1$*2$" , err_term);
111+ FailFmtWithError<2 >(" %1$.*2$" , err_term);
112+ FailFmtWithError<2 >(" %1$9.*2$" , err_term);
83113}
84114
85115BOOST_AUTO_TEST_SUITE_END ()
0 commit comments