]>
git.proxmox.com Git - ceph.git/blob - ceph/src/fmt/test/enforce-checks-test.cc
1 // Formatting library for C++ - formatting library tests
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
6 // For the license information refer to format.h.
11 #include "fmt/chrono.h"
12 #include "fmt/color.h"
13 #include "fmt/format.h"
14 #include "fmt/ostream.h"
15 #include "fmt/ranges.h"
16 #include "fmt/xchar.h"
18 // Exercise the API to verify that everything we expect to can compile.
19 void test_format_api() {
20 fmt::format(FMT_STRING("{}"), 42);
21 fmt::format(FMT_STRING(L
"{}"), 42);
22 fmt::format(FMT_STRING("noop"));
27 std::vector
<char> out
;
28 fmt::format_to(std::back_inserter(out
), FMT_STRING("{}"), 42);
31 fmt::format_to_n(buffer
, 3, FMT_STRING("{}"), 12345);
34 fmt::format_to_n(wbuffer
, 3, FMT_STRING(L
"{}"), 12345);
38 fmt::format(FMT_STRING("{}"), std::chrono::seconds(42));
39 fmt::format(FMT_STRING(L
"{}"), std::chrono::seconds(42));
42 void test_text_style() {
43 fmt::print(fg(fmt::rgb(255, 20, 30)), FMT_STRING("{}"), "rgb(255,20,30)");
44 fmt::format(fg(fmt::rgb(255, 20, 30)), FMT_STRING("{}"), "rgb(255,20,30)");
46 fmt::text_style ts
= fg(fmt::rgb(255, 20, 30));
48 fmt::format_to(std::back_inserter(out
), ts
,
49 FMT_STRING("rgb(255,20,30){}{}{}"), 1, 2, 3);
53 std::vector
<char> hello
= {'h', 'e', 'l', 'l', 'o'};
54 fmt::format(FMT_STRING("{}"), hello
);