Add color format_to overloads

* Fix variable size basic_memory_buffer colorization
* Fix an unused arguments warning on GCC that blocks the CI otherwise
* Ref #1842
* Ref #1593
This commit is contained in:
Denis Blank
2020-09-06 08:24:15 -07:00
committed by Victor Zverovich
parent f19b8885f2
commit bff4d18efb
3 changed files with 56 additions and 4 deletions
+13
View File
@@ -7,6 +7,10 @@
#include "fmt/color.h"
#include <iterator>
#include <string>
#include <utility>
#include "gtest-extra.h"
TEST(ColorsTest, ColorsPrint) {
@@ -84,3 +88,12 @@ TEST(ColorsTest, Format) {
EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), "{}", "foo"),
"\x1b[31mfoo\x1b[0m");
}
TEST(ColorsTest, FormatToOutAcceptsTextStyle) {
fmt::text_style const ts = fg(fmt::rgb(255, 20, 30));
std::string out;
fmt::format_to(std::back_inserter(out), ts, "rgb(255,20,30){}{}{}", 1, 2, 3);
EXPECT_EQ(fmt::to_string(out),
"\x1b[38;2;255;020;030mrgb(255,20,30)123\x1b[0m");
}