mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 06:21:00 +00:00
Fix format overload that takes text_style (#1305)
This commit is contained in:
parent
c85ae23c73
commit
0656045d02
@ -576,8 +576,9 @@ inline std::basic_string<Char> vformat(
|
|||||||
template <typename S, typename... Args, typename Char = char_t<S> >
|
template <typename S, typename... Args, typename Char = char_t<S> >
|
||||||
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
|
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
|
||||||
const Args&... args) {
|
const Args&... args) {
|
||||||
return internal::vformat(ts, to_string_view(format_str),
|
return internal::vformat(
|
||||||
{internal::make_args_checked(format_str, args...)});
|
ts, to_string_view(format_str),
|
||||||
|
{internal::make_args_checked<Args...>(format_str, args...)});
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
|
@ -47,7 +47,7 @@ TEST(ColorsTest, ColorsPrint) {
|
|||||||
"\x1b[105mtbmagenta\x1b[0m");
|
"\x1b[105mtbmagenta\x1b[0m");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ColorsTest, ColorsFormat) {
|
TEST(ColorsTest, Format) {
|
||||||
EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 20, 30)), "rgb(255,20,30)"),
|
EXPECT_EQ(fmt::format(fg(fmt::rgb(255, 20, 30)), "rgb(255,20,30)"),
|
||||||
"\x1b[38;2;255;020;030mrgb(255,20,30)\x1b[0m");
|
"\x1b[38;2;255;020;030mrgb(255,20,30)\x1b[0m");
|
||||||
EXPECT_EQ(fmt::format(fg(fmt::color::blue), "blue"),
|
EXPECT_EQ(fmt::format(fg(fmt::color::blue), "blue"),
|
||||||
@ -78,4 +78,6 @@ TEST(ColorsTest, ColorsFormat) {
|
|||||||
"\x1b[92mtbgreen\x1b[0m");
|
"\x1b[92mtbgreen\x1b[0m");
|
||||||
EXPECT_EQ(fmt::format(bg(fmt::terminal_color::bright_magenta), "tbmagenta"),
|
EXPECT_EQ(fmt::format(bg(fmt::terminal_color::bright_magenta), "tbmagenta"),
|
||||||
"\x1b[105mtbmagenta\x1b[0m");
|
"\x1b[105mtbmagenta\x1b[0m");
|
||||||
|
EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), "{}", "foo"),
|
||||||
|
"\x1b[31mfoo\x1b[0m");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user