SectionPairMessageFormatterTest.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-22
  6. * Changed: 2023-02-23
  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. protected:
  24. SectionPairMessageFormatterTest() = default;
  25. ~SectionPairMessageFormatterTest() override = default;
  26. void SetUp() override
  27. {}
  28. void TearDown() override
  29. {}
  30. public:
  31. static string getFormattedExampleMessage(const string &_replacementString)
  32. {
  33. string formattedMessage = _replacementString + "[general]" + _replacementString + _replacementString;
  34. formattedMessage += "name=Tina" + _replacementString;
  35. formattedMessage += "age=17" + _replacementString;
  36. formattedMessage += "birthday=25.01.2006" + _replacementString;
  37. return formattedMessage;
  38. }
  39. static string getOriginalExampleMessage(const string &_newLine)
  40. {
  41. string formattedMessage = _newLine + "[general]" + _newLine + _newLine;
  42. formattedMessage += "name=Tina" + _newLine;
  43. formattedMessage += "age=17" + _newLine;
  44. formattedMessage += "birthday=25.01.2006" + _newLine;
  45. return formattedMessage;
  46. }
  47. };
  48. TEST_P(SectionPairMessageFormatterTest, getFormattedMessage)
  49. {
  50. string expected = GetParam().at(0);
  51. string actual = SectionPairMessageFormatter::getFormattedMessage(GetParam().at(1));
  52. ASSERT_STREQ(expected.c_str(), actual.c_str());
  53. }
  54. 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")}));
  55. }