pattern_layout_test.cxx 937 B

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