SectionPairMessageFormatterTest.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-22
  7. *
  8. * */
  9. #include <array>
  10. #include <gtest/gtest.h>
  11. #include <ls-std/ls-std-io.hpp>
  12. #include <string>
  13. using namespace ls::std::io;
  14. using namespace ::std;
  15. using namespace ::testing;
  16. namespace
  17. {
  18. class SectionPairMessageFormatterTest : public TestWithParam<array<string, 2>>
  19. {
  20. protected:
  21. SectionPairMessageFormatterTest() = default;
  22. ~SectionPairMessageFormatterTest() override = default;
  23. void SetUp() override
  24. {}
  25. void TearDown() override
  26. {}
  27. public:
  28. static string getFormattedExampleMessage(const string &_replacementString)
  29. {
  30. string formattedMessage = _replacementString + "[general]" + _replacementString + _replacementString;
  31. formattedMessage += "name=Tina" + _replacementString;
  32. formattedMessage += "age=17" + _replacementString;
  33. formattedMessage += "birthday=25.01.2006" + _replacementString;
  34. return formattedMessage;
  35. }
  36. static string getOriginalExampleMessage(const string &_newLine)
  37. {
  38. string formattedMessage = _newLine + "[general]" + _newLine + _newLine;
  39. formattedMessage += "name=Tina" + _newLine;
  40. formattedMessage += "age=17" + _newLine;
  41. formattedMessage += "birthday=25.01.2006" + _newLine;
  42. return formattedMessage;
  43. }
  44. };
  45. TEST_P(SectionPairMessageFormatterTest, getFormattedMessage)
  46. {
  47. string expected = GetParam().at(0);
  48. string actual = SectionPairMessageFormatter::getFormattedMessage(GetParam().at(1));
  49. ASSERT_STREQ(expected.c_str(), actual.c_str());
  50. }
  51. 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")}));
  52. }