FileWriterTest.cpp 980 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-08-17
  6. * Changed: 2020-08-17
  7. *
  8. * */
  9. #include <gtest/gtest.h>
  10. #include "../../../source/io/File.hpp"
  11. #include "../../../source/io/FileWriter.hpp"
  12. #include "../../TestHelper.hpp"
  13. namespace {
  14. class FileWriterTest : public ::testing::Test {
  15. protected:
  16. FileWriterTest() = default;
  17. ~FileWriterTest() override = default;
  18. void SetUp() override {}
  19. void TearDown() override {}
  20. };
  21. TEST_F(FileWriterTest, write)
  22. {
  23. std::string path = TestHelper::getResourcesFolderLocation() + "tmp_file_writer_test.txt";
  24. ls_std::File file {path};
  25. ASSERT_FALSE(file.exists());
  26. file.createNewFile();
  27. ASSERT_TRUE(file.exists());
  28. ls_std::FileWriter writer {file};
  29. ASSERT_TRUE(writer.write("Testing something!\n"));
  30. file.remove();
  31. ASSERT_FALSE(file.exists());
  32. }
  33. }