MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/util_string_tests.cpp:45–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45BOOST_AUTO_TEST_CASE(ConstevalFormatString_NumSpec)
46{
47 PassFmt<0>("");
48 PassFmt<0>("%%");
49 PassFmt<1>("%s");
50 PassFmt<1>("%c");
51 PassFmt<0>("%%s");
52 PassFmt<0>("s%%");
53 PassFmt<1>("%%%s");
54 PassFmt<1>("%s%%");
55 PassFmt<0>(" 1$s");
56 PassFmt<1>("%1$s");
57 PassFmt<1>("%1$s%1$s");
58 PassFmt<2>("%2$s");
59 PassFmt<2>("%2$s 4$s %2$s");
60 PassFmt<129>("%129$s 999$s %2$s");
61 PassFmt<1>("%02d");
62 PassFmt<1>("%+2s");
63 PassFmt<1>("%.6i");
64 PassFmt<1>("%5.2f");
65 PassFmt<1>("%5.f");
66 PassFmt<1>("%.f");
67 PassFmt<1>("%#x");
68 PassFmt<1>("%1$5i");
69 PassFmt<1>("%1$-5i");
70 PassFmt<1>("%1$.5i");
71 // tinyformat accepts almost any "type" spec, even '%', or '_', or '\n'.
72 PassFmt<1>("%123%");
73 PassFmt<1>("%123%s");
74 PassFmt<1>("%_");
75 PassFmt<1>("%\n");
76
77 PassFmt<2>("%*c");
78 PassFmt<2>("%+*c");
79 PassFmt<2>("%.*f");
80 PassFmt<3>("%*.*f");
81 PassFmt<3>("%2$*3$d");
82 PassFmt<3>("%2$*3$.9d");
83 PassFmt<3>("%2$.*3$d");
84 PassFmt<3>("%2$9.*3$d");
85 PassFmt<3>("%2$+9.*3$d");
86 PassFmt<4>("%3$*2$.*4$f");
87
88 // Make sure multiple flag characters "- 0+" are accepted
89 PassFmt<3>("'%- 0+*.*f'");
90 PassFmt<3>("'%1$- 0+*3$.*2$f'");
91
92 auto err_mix{"Format specifiers must be all positional or all non-positional!"};
93 FailFmtWithError<1>("%s%1$s", err_mix);
94 FailFmtWithError<2>("%2$*d", err_mix);
95 FailFmtWithError<2>("%*2$d", err_mix);
96 FailFmtWithError<2>("%.*3$d", err_mix);
97 FailFmtWithError<2>("%2$.*d", err_mix);
98
99 auto err_num{"Format specifier count must match the argument count!"};
100 FailFmtWithError<1>("", err_num);
101 FailFmtWithError<0>("%s", err_num);
102 FailFmtWithError<2>("%s", err_num);

Callers

nothing calls this directly

Calls 7

CaseInsensitiveEqualFunction · 0.85
ConsumedMethod · 0.80
RemainingMethod · 0.80
ReadLineMethod · 0.80
ReadLengthMethod · 0.80
formatFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected