add fmt::print() overload to support compiled format (#2304)

This commit is contained in:
Alexey Ochapov
2021-05-26 00:54:56 +03:00
committed by GitHub
parent 82607efb57
commit ee52a6dc40
4 changed files with 37 additions and 5 deletions

View File

@ -11,6 +11,7 @@
#include "fmt/chrono.h"
#include "gmock/gmock.h"
#include "gtest-extra.h"
TEST(iterator_test, counting_iterator) {
auto it = fmt::detail::counting_iterator();
@ -241,6 +242,13 @@ FMT_END_NAMESPACE
TEST(compile_test, to_string_and_formatter) {
fmt::format(FMT_COMPILE("{}"), to_stringable());
}
TEST(compile_test, print) {
EXPECT_WRITE(stdout, fmt::print(FMT_COMPILE("Don't {}!"), "panic"),
"Don't panic!");
EXPECT_WRITE(stderr, fmt::print(stderr, FMT_COMPILE("Don't {}!"), "panic"),
"Don't panic!");
}
#endif
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS