SectionPairFileReaderIT.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-02-21
  6. * Changed: 2023-05-16
  7. *
  8. * */
  9. #include <classes/TestHelper.hpp>
  10. #include <gtest/gtest.h>
  11. #include <ls-std/ls-std-core.hpp>
  12. #include <ls-std/ls-std-io.hpp>
  13. #include <string>
  14. using ls::std::io::SectionPairDocument;
  15. using ls::std::io::SectionPairFileReader;
  16. using ls::std::io::SectionPairFileReaderParameter;
  17. using ls::std::test::TestHelper;
  18. using std::make_shared;
  19. using std::shared_ptr;
  20. using std::string;
  21. using testing::Test;
  22. namespace
  23. {
  24. class SectionPairFileReaderIT : public Test
  25. {
  26. public:
  27. SectionPairFileReaderIT() = default;
  28. ~SectionPairFileReaderIT() override = default;
  29. static string getSectionPairFileLocation()
  30. {
  31. return TestHelper::getResourcesFolderLocation() + "server-settings-unix.txt";
  32. }
  33. };
  34. TEST_F(SectionPairFileReaderIT, read)
  35. {
  36. SectionPairFileReaderParameter parameter{};
  37. auto document = make_shared<SectionPairDocument>();
  38. parameter.setDocument(document);
  39. parameter.setFilePath(SectionPairFileReaderIT::getSectionPairFileLocation());
  40. SectionPairFileReader reader{parameter};
  41. reader.read();
  42. ASSERT_TRUE(!reader.getDocument()->getSectionList().empty());
  43. ASSERT_STREQ("general", reader.getDocument()->get(0)->getSectionId().c_str());
  44. ASSERT_EQ(2, reader.getDocument()->get(0)->getRowAmount());
  45. }
  46. }