Add format_to_n overload that accepts FMT_COMPILE (from #1767) (#1869)

* Add format_to_n overload that accepts FMT_COMPILE

* add FormatToNWithCompileMacro test into CompileTest

Co-authored-by: Dmitriy Kurkin <Dmitriy.Kurkin@itiviti.com>
This commit is contained in:
Alexey Ochapov
2020-09-15 07:28:06 -07:00
committed by GitHub
co-authored by Dmitriy Kurkin
parent 5b5a597198
commit f674434a67
2 changed files with 18 additions and 0 deletions
+8
View File
@@ -165,6 +165,14 @@ TEST(CompileTest, FormatTo) {
EXPECT_STREQ("42", buf);
}
TEST(CompileTest, FormatToNWithCompileMacro) {
constexpr auto buffer_size = 8;
char buffer[buffer_size];
auto res = fmt::format_to_n(buffer, buffer_size, FMT_COMPILE("{}"), 42);
*res.out = '\0';
EXPECT_STREQ("42", buffer);
}
TEST(CompileTest, TextAndArg) {
EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42));
EXPECT_EQ("42!", fmt::format(FMT_COMPILE("{}!"), 42));