Debian Codegraph @

libstdc++-v3/testsuite/std/format/functions/size.cc

raw
1 // { dg-do run { target c++20 } }
2
3 #include <format>
4 #include <string>
5 #include <testsuite_hooks.h>
6
7 void
8 test()
9 {
10 auto n = std::formatted_size("");
11 static_assert( std::is_same_v<std::size_t, decltype(n)> );
12 VERIFY( n == 0 );
13
14 n = std::formatted_size("abc");
15 VERIFY( n == 3 );
16
17 n = std::formatted_size("{{abc}}");
18 VERIFY( n == 5 );
19
20 n = std::formatted_size("{{{}}}", 1);
21 VERIFY( n == 3 );
22
23 n = std::formatted_size("{{{}}}", "abc");
24 VERIFY( n == 5 );
25 }
26
27 void
28 test_wchar()
29 {
30 auto n = std::formatted_size(L"");
31 static_assert( std::is_same_v<std::size_t, decltype(n)> );
32 VERIFY( n == 0 );
33
34 n = std::formatted_size(L"abc");
35 VERIFY( n == 3 );
36
37 n = std::formatted_size(L"{{abc}}");
38 VERIFY( n == 5 );
39
40 n = std::formatted_size(L"{{{}}}", 1);
41 VERIFY( n == 3 );
42
43 n = std::formatted_size(L"{{{}}}", L"abc");
44 VERIFY( n == 5 );
45 }
46
47 int main()
48 {
49 test();
50 test_wchar();
51 }