add print tests
This commit is contained in:
parent
d029b2db15
commit
8fd0746abf
@ -22,6 +22,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fmt/compile.h"
|
#include "fmt/compile.h"
|
||||||
|
#include "fmt/ostream.h"
|
||||||
#include "gmock.h"
|
#include "gmock.h"
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
#include "mock-allocator.h"
|
#include "mock-allocator.h"
|
||||||
@ -141,3 +142,20 @@ TEST(CompileTest, EmptyFormatString) {
|
|||||||
auto f = fmt::compile<>("");
|
auto f = fmt::compile<>("");
|
||||||
EXPECT_EQ(fmt::format(f), "");
|
EXPECT_EQ(fmt::format(f), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(CompileTest, Print) {
|
||||||
|
std::ostringstream os;
|
||||||
|
auto f = fmt::compile<fmt::string_view>("Don't {}!");
|
||||||
|
fmt::print(os, f, "panic");
|
||||||
|
EXPECT_EQ("Don't panic!", os.str());
|
||||||
|
|
||||||
|
auto wf = fmt::compile<fmt::wstring_view>(L"Don't {}!");
|
||||||
|
std::wostringstream wos;
|
||||||
|
fmt::print(wos, wf, L"panic");
|
||||||
|
EXPECT_EQ(L"Don't panic!", wos.str());
|
||||||
|
|
||||||
|
#if FMT_USE_FILE_DESCRIPTORS
|
||||||
|
EXPECT_WRITE(stdout, fmt::print(f, "panic"), "Don't panic!");
|
||||||
|
EXPECT_WRITE(stderr, fmt::print(stderr, f, "panic"), "Don't panic!");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user