Commit 0656045d authored by Victor Zverovich's avatar Victor Zverovich

Fix format overload that takes text_style (#1305)

parent c85ae23c
...@@ -576,8 +576,9 @@ inline std::basic_string<Char> vformat( ...@@ -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) { ...@@ -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) { ...@@ -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");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment