Fix format overload that takes text_style (#1305)

This commit is contained in:
Victor Zverovich 2019-09-08 18:41:02 -07:00
parent c85ae23c73
commit 0656045d02
2 changed files with 6 additions and 3 deletions

View File

@ -576,8 +576,9 @@ inline std::basic_string<Char> vformat(
template <typename S, typename... Args, typename Char = char_t<S> >
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
const Args&... args) {
return internal::vformat(ts, to_string_view(format_str),
{internal::make_args_checked(format_str, args...)});
return internal::vformat(
ts, to_string_view(format_str),
{internal::make_args_checked<Args...>(format_str, args...)});
}
FMT_END_NAMESPACE

View File

@ -47,7 +47,7 @@ TEST(ColorsTest, ColorsPrint) {
"\x1b[105mtbmagenta\x1b[0m");
}
TEST(ColorsTest, ColorsFormat) {
TEST(ColorsTest, Format) {
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");
EXPECT_EQ(fmt::format(fg(fmt::color::blue), "blue"),
@ -78,4 +78,6 @@ TEST(ColorsTest, ColorsFormat) {
"\x1b[92mtbgreen\x1b[0m");
EXPECT_EQ(fmt::format(bg(fmt::terminal_color::bright_magenta), "tbmagenta"),
"\x1b[105mtbmagenta\x1b[0m");
EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), "{}", "foo"),
"\x1b[31mfoo\x1b[0m");
}