| 12345678910111213141516171819202122232425262728293031323334353637 |
- //
- // pattern_layout_test.cxx
- // logger_test
- //
- // Created by Sam Jaffe on 4/13/19.
- //
- #include <gmock/gmock.h>
- #include "resource_factory/prototype_factory.hpp"
- #include "logger/detail/layout.h"
- #include "logger/log_manager.h"
- #include "logger/logpacket.h"
- #include "logger/properties.h"
- // Thursday, April 4, 2019 6:17:20 PM GMT
- namespace {
- constexpr const int NOW = 1554401840;
- }
- TEST(PatternLayoutTest, TestInvokesFormatter) {
- using namespace logging;
- using namespace logging::property;
- properties props{_obj({
- {"pattern", _v("%d{%I:%M:%S.%_ms} [%%] %-5.5p %.36c - %m")}
- })};
- auto playout = layouts::instance().get("PatternLayout", props);
-
- std::stringstream ss;
- playout->format(ss, {{NOW, 0}, level::warning, {}, "UnitTest",
- "This is a test message"});
-
- using testing::Eq;
- EXPECT_THAT(ss.str(), Eq("06:17:20.000 [%] WARNI UnitTest -"
- " This is a test message"));
- }
|