format_test.cxx 762 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // format_test.cxx
  3. // logger_test
  4. //
  5. // Created by Sam Jaffe on 4/4/19.
  6. //
  7. #include <gmock/gmock.h>
  8. #include "logger/exception.h"
  9. #include "logger/format.h"
  10. using namespace logging;
  11. TEST(FormatTest, EmptyFormatterCanParse) {
  12. EXPECT_NO_THROW(format::parse_format_string(""));
  13. }
  14. TEST(FormatTest, ThrowsForEndOfStringAfterPct) {
  15. EXPECT_THROW(format::parse_format_string("%"),
  16. format_parsing_exception);
  17. }
  18. TEST(FormatTest, RawStringFmtReturnsSelf) {
  19. using testing::Eq;
  20. auto fmt = format::parse_format_string("TEST STRING");
  21. EXPECT_THAT(fmt.process({}), Eq("TEST STRING"));
  22. }
  23. TEST(FormatTest, NCharReturnsNewLine) {
  24. using testing::Eq;
  25. auto fmt = format::parse_format_string("%n");
  26. EXPECT_THAT(fmt.process({}), Eq("\n"));
  27. }