SectionPairMessageFormatterTest.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. namespace
  16. {
  17. class SectionPairMessageFormatterTest : public ::testing::TestWithParam<array<string, 2>>
  18. {
  19. protected:
  20. SectionPairMessageFormatterTest() = default;
  21. ~SectionPairMessageFormatterTest() override = default;
  22. void SetUp() override
  23. {}
  24. void TearDown() override
  25. {}
  26. public:
  27. static string getFormattedExampleMessage(const string &_replacementString)
  28. {
  29. string formattedMessage = _replacementString + "[general]" + _replacementString + _replacementString;
  30. formattedMessage += "name=Tina" + _replacementString;
  31. formattedMessage += "age=17" + _replacementString;
  32. formattedMessage += "birthday=25.01.2006" + _replacementString;
  33. return formattedMessage;
  34. }
  35. static string getOriginalExampleMessage(const string &_newLine)
  36. {
  37. string formattedMessage = _newLine + "[general]" + _newLine + _newLine;
  38. formattedMessage += "name=Tina" + _newLine;
  39. formattedMessage += "age=17" + _newLine;
  40. formattedMessage += "birthday=25.01.2006" + _newLine;
  41. return formattedMessage;
  42. }
  43. };
  44. TEST_P(SectionPairMessageFormatterTest, getFormattedMessage)
  45. {
  46. string expected = GetParam().at(0);
  47. string actual = SectionPairMessageFormatter::getFormattedMessage(GetParam().at(1));
  48. ASSERT_STREQ(expected.c_str(), actual.c_str());
  49. }
  50. INSTANTIATE_TEST_SUITE_P(ValidArgumentTest, SectionPairMessageFormatterTest, ::testing::Values(array<string, 2>{SectionPairMessageFormatterTest::getFormattedExampleMessage("{UNIX_LINE_BREAK}"), SectionPairMessageFormatterTest::getOriginalExampleMessage("\n")}, array<string, 2>{SectionPairMessageFormatterTest::getFormattedExampleMessage("{WINDOWS_LINE_BREAK}"), SectionPairMessageFormatterTest::getOriginalExampleMessage("\r\n")}));
  51. }