Skip to content

Commit

Permalink
Fix format overload that takes text_style (fmtlib#1305)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 9, 2019
1 parent c85ae23 commit 0656045
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/color-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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");
}

0 comments on commit 0656045

Please sign in to comment.