SectionPairMessageFormatterTest.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-22
  6. * Changed: 2023-03-25
  7. *
  8. * */
  9. #include <array>
  10. #include <gtest/gtest.h>
  11. #include <ls-std/ls-std-io.hpp>
  12. #include <string>
  13. using ls::std::io::SectionPairMessageFormatter;
  14. using std::array;
  15. using std::string;
  16. using testing::Test;
  17. using testing::TestWithParam;
  18. using testing::Values;
  19. namespace
  20. {
  21. class SectionPairMessageFormatterTest : public TestWithParam<array<string, 2>>
  22. {
  23. public:
  24. SectionPairMessageFormatterTest() = default;
  25. ~SectionPairMessageFormatterTest() override = default;
  26. static string getFormattedExampleMessage(const string &_replacementString)
  27. {
  28. string formattedMessage = _replacementString + "[general]" + _replacementString + _replacementString;
  29. formattedMessage += "name=Tina" + _replacementString;
  30. formattedMessage += "age=17" + _replacementString;
  31. formattedMessage += "birthday=25.01.2006" + _replacementString;
  32. return formattedMessage;
  33. }
  34. static string getOriginalExampleMessage(const string &_newLine)
  35. {
  36. string formattedMessage = _newLine + "[general]" + _newLine + _newLine;
  37. formattedMessage += "name=Tina" + _newLine;
  38. formattedMessage += "age=17" + _newLine;
  39. formattedMessage += "birthday=25.01.2006" + _newLine;
  40. return formattedMessage;
  41. }
  42. };
  43. TEST_P(SectionPairMessageFormatterTest, getFormattedMessage)
  44. {
  45. string expected = GetParam().at(0);
  46. string actual = SectionPairMessageFormatter::getFormattedMessage(GetParam().at(1));
  47. ASSERT_STREQ(expected.c_str(), actual.c_str());
  48. }
  49. INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairMessageFormatterTest, Values(array<string, 2>{SectionPairMessageFormatterTest::getFormattedExampleMessage("{UNIX_LINE_BREAK}"), SectionPairMessageFormatterTest::getOriginalExampleMessage("\n")}, array<string, 2>{SectionPairMessageFormatterTest::getFormattedExampleMessage("{WINDOWS_LINE_BREAK}"), SectionPairMessageFormatterTest::getOriginalExampleMessage("\r\n")}));
  50. }