|
|
@@ -37,8 +37,8 @@ std::string DoFormat(std::string const & fmt,
|
|
|
|
|
|
using namespace logging;
|
|
|
|
|
|
-logpacket getpkt(std::string const & msg) {
|
|
|
- return logpacket{{}, level::error, {}, "UNIT_TEST", msg};
|
|
|
+logpacket getpkt(std::string const & msg, location_info info = {}) {
|
|
|
+ return logpacket{{}, level::error, info, "UNIT_TEST", msg};
|
|
|
};
|
|
|
|
|
|
TEST(PatternLayoutTest, EmptyFormatterCanParse) {
|
|
|
@@ -153,6 +153,21 @@ TEST(PatternLayoutTest, LogMessageIsMToken) {
|
|
|
Eq("HELLO"));
|
|
|
}
|
|
|
|
|
|
+TEST(PatternLayoutTest, CanOutputLineNumber) {
|
|
|
+ EXPECT_THAT(std::stoi(DoFormat("%L", getpkt("", log_here))),
|
|
|
+ testing::Eq(__LINE__ - 1));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(PatternLayoutTest, CanOutputFileName) {
|
|
|
+ EXPECT_THAT(DoFormat("%F", getpkt("", log_here)),
|
|
|
+ testing::EndsWith("pattern_layout_test.cxx"));
|
|
|
+}
|
|
|
+
|
|
|
+TEST(PatternLayoutTest, CanOutputCallingMethod) {
|
|
|
+ EXPECT_THAT(DoFormat("%M", getpkt("", log_here)),
|
|
|
+ testing::Eq("TestBody"));
|
|
|
+}
|
|
|
+
|
|
|
TEST(PatternLayoutTest, ThrowsOnUnknownToken) {
|
|
|
using testing::Eq;
|
|
|
EXPECT_THROW(GetPatternLayout("%q"),
|