SectionPairMessageFormatterTest.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Co-Author: Claude Sonnet 4.6 (LLM)
  4. * Company: Lynar Studios
  5. * E-Mail: webmaster@lynarstudios.com
  6. * Created: 2023-02-22
  7. * Changed: 2026-06-23
  8. *
  9. * */
  10. #include <array>
  11. #include <gtest/gtest.h>
  12. #include <ls-std/ls-std-io.hpp>
  13. #include <string>
  14. using ls::standard::io::SectionPairMessageFormatter;
  15. using std::array;
  16. using std::string;
  17. using testing::Test;
  18. using testing::TestWithParam;
  19. using testing::Values;
  20. namespace
  21. {
  22. class SectionPairMessageFormatterTest : public TestWithParam<array<string, 2>>
  23. {
  24. public:
  25. SectionPairMessageFormatterTest() = default;
  26. ~SectionPairMessageFormatterTest() override = default;
  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. const string expected = GetParam().at(0);
  47. const string actual = SectionPairMessageFormatter::getFormattedMessage(GetParam().at(1));
  48. ASSERT_STREQ(expected.c_str(), actual.c_str());
  49. }
  50. 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")}));
  51. }