| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // json_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"
- TEST(JsonLayoutTest, CanConstructWithNoConfig) {
- EXPECT_NO_THROW(logging::layouts::instance().get("JsonLayout", {}));
- }
- // Thursday, April 4, 2019 6:17:20 PM GMT
- namespace {
- constexpr const int NOW = 1554401840;
- }
- std::string const formatted_output = R"({
- "instant": {
- "epochSecond": 1554401840,
- "nanoOfSecond": 123456000
- }
- "level": "warning",
- "loggerName": "UnitTest",
- "message": "This is a test message"
- })";
- TEST(JsonLayoutTest, TestInvokesFormatter) {
- using namespace logging;
- auto playout = layouts::instance().get("JsonLayout", {});
-
- std::stringstream ss;
- playout->format(ss, {{NOW, 123456}, level::warning, {}, "UnitTest",
- "This is a test message"});
-
- using testing::Eq;
- EXPECT_THAT(ss.str(), Eq(formatted_output));
- }
|