|
@@ -3,7 +3,7 @@
|
|
* Company: Lynar Studios
|
|
* Company: Lynar Studios
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
* Created: 2020-08-19
|
|
* Created: 2020-08-19
|
|
- * Changed: 2020-08-19
|
|
|
|
|
|
+ * Changed: 2020-08-22
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
|
|
|
|
@@ -25,40 +25,43 @@ namespace {
|
|
void TearDown() override {}
|
|
void TearDown() override {}
|
|
};
|
|
};
|
|
|
|
|
|
- TEST_F(StorableFileTest, getContent)
|
|
|
|
|
|
+ TEST_F(StorableFileTest, getFile)
|
|
{
|
|
{
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
- ASSERT_TRUE(storableFile.getContent().empty());
|
|
|
|
|
|
+ ASSERT_STREQ(this->fileLocation.c_str(), storableFile.getFile()->getAbsoluteFilePath().c_str());
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(StorableFileTest, load)
|
|
TEST_F(StorableFileTest, load)
|
|
{
|
|
{
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
- storableFile.load();
|
|
|
|
|
|
+ std::string content = {storableFile.load(), (size_t) storableFile.getFile()->getSize()};
|
|
|
|
+
|
|
std::string expectedUnix = "Hello!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string expectedUnix = "Hello!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string expectedWindows = "Hello!" + ls_std::NewLine::getWindowsNewLine();
|
|
std::string expectedWindows = "Hello!" + ls_std::NewLine::getWindowsNewLine();
|
|
|
|
|
|
- ASSERT_TRUE(storableFile.getContent() == expectedUnix || storableFile.getContent() == expectedWindows);
|
|
|
|
|
|
+ ASSERT_TRUE(content == expectedUnix || content == expectedWindows);
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(StorableFileTest, reset)
|
|
TEST_F(StorableFileTest, reset)
|
|
{
|
|
{
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
ls_std::StorableFile storableFile {this->fileLocation};
|
|
- storableFile.load();
|
|
|
|
|
|
+ std::string content = {storableFile.load(), (size_t) storableFile.getFile()->getSize()};
|
|
|
|
+
|
|
std::string expectedUnix = "Hello!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string expectedUnix = "Hello!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string expectedWindows = "Hello!" + ls_std::NewLine::getWindowsNewLine();
|
|
std::string expectedWindows = "Hello!" + ls_std::NewLine::getWindowsNewLine();
|
|
|
|
|
|
- ASSERT_TRUE(storableFile.getContent() == expectedUnix || storableFile.getContent() == expectedWindows);
|
|
|
|
|
|
+ ASSERT_TRUE(content == expectedUnix || content == expectedWindows);
|
|
|
|
|
|
// reset
|
|
// reset
|
|
|
|
|
|
std::string anotherFileLocation = TestHelper::getResourcesFolderLocation() + "list_test/bla.txt";
|
|
std::string anotherFileLocation = TestHelper::getResourcesFolderLocation() + "list_test/bla.txt";
|
|
storableFile.reset(anotherFileLocation);
|
|
storableFile.reset(anotherFileLocation);
|
|
- storableFile.load();
|
|
|
|
|
|
+ content = {storableFile.load(), (size_t) storableFile.getFile()->getSize()};
|
|
|
|
+
|
|
expectedUnix = "nothing to say!" + ls_std::NewLine::getUnixNewLine();
|
|
expectedUnix = "nothing to say!" + ls_std::NewLine::getUnixNewLine();
|
|
expectedWindows = "nothing to say!" + ls_std::NewLine::getWindowsNewLine();
|
|
expectedWindows = "nothing to say!" + ls_std::NewLine::getWindowsNewLine();
|
|
|
|
|
|
- ASSERT_TRUE(storableFile.getContent() == expectedUnix || storableFile.getContent() == expectedWindows);
|
|
|
|
|
|
+ ASSERT_TRUE(content == expectedUnix || content == expectedWindows);
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(StorableFileTest, save)
|
|
TEST_F(StorableFileTest, save)
|
|
@@ -71,21 +74,10 @@ namespace {
|
|
std::string textUnix = "Testing save method!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string textUnix = "Testing save method!" + ls_std::NewLine::getUnixNewLine();
|
|
std::string textWindows = "Testing save method!" + ls_std::NewLine::getWindowsNewLine();
|
|
std::string textWindows = "Testing save method!" + ls_std::NewLine::getWindowsNewLine();
|
|
|
|
|
|
- ASSERT_TRUE(storableFile.getContent().empty());
|
|
|
|
- storableFile.setContent(textUnix);
|
|
|
|
- ASSERT_TRUE(storableFile.getContent() == textUnix || storableFile.getContent() == textWindows);
|
|
|
|
- storableFile.save();
|
|
|
|
- storableFile.load();
|
|
|
|
- ASSERT_TRUE(storableFile.getContent() == textUnix || storableFile.getContent() == textWindows);
|
|
|
|
|
|
+ storableFile.save((char*) textUnix.c_str());
|
|
|
|
+ std::string content = storableFile.load();
|
|
|
|
+ ASSERT_TRUE(content == textUnix || content == textWindows);
|
|
|
|
|
|
file.remove();
|
|
file.remove();
|
|
}
|
|
}
|
|
-
|
|
|
|
- TEST_F(StorableFileTest, setContent)
|
|
|
|
- {
|
|
|
|
- ls_std::StorableFile storableFile {this->fileLocation};
|
|
|
|
- storableFile.setContent("Testing!");
|
|
|
|
-
|
|
|
|
- ASSERT_STREQ("Testing!", storableFile.getContent().c_str());
|
|
|
|
- }
|
|
|
|
}
|
|
}
|