add WithOstreamOperator test into CompileTest

to check fmt::format() with FMT_COMPILE() and class that has output stream operator
This commit is contained in:
Alexey Ochapov 2020-08-18 20:04:49 +03:00
parent 3acbd494b1
commit b1a55bc099
No known key found for this signature in database
GPG Key ID: 740E711C3D542558

View File

@ -23,6 +23,7 @@
#endif
#include "fmt/compile.h"
#include "fmt/ostream.h"
#include "gmock.h"
#include "gtest-extra.h"
#include "mock-allocator.h"
@ -169,4 +170,15 @@ TEST(CompileTest, TextAndArg) {
EXPECT_EQ(">>>42<<<", fmt::format(FMT_COMPILE(">>>{}<<<"), 42));
EXPECT_EQ("42!", fmt::format(FMT_COMPILE("{}!"), 42));
}
struct ostream_operator_test {};
std::ostream& operator<<(std::ostream& os, ostream_operator_test) {
return os << "42";
}
TEST(CompileTest, WithOstreamOperator) {
EXPECT_EQ("42", fmt::format(FMT_COMPILE("{}"), ostream_operator_test()));
}
#endif