|
|
@@ -3,7 +3,7 @@
|
|
|
* Company: Lynar Studios
|
|
|
* E-Mail: webmaster@lynarstudios.com
|
|
|
* Created: 2020-08-15
|
|
|
- * Changed: 2025-12-21
|
|
|
+ * Changed: 2025-12-23
|
|
|
*
|
|
|
* */
|
|
|
|
|
|
@@ -66,7 +66,7 @@ namespace
|
|
|
TEST_F(FileTest, canExecute)
|
|
|
{
|
|
|
#ifdef _WIN32
|
|
|
- File executableFile{TestHelper::getResourcesFolderLocation() + "app.exe"};
|
|
|
+ const File executableFile{TestHelper::getResourcesFolderLocation() + "app.exe"};
|
|
|
#endif
|
|
|
#if defined(unix) || defined(__APPLE__)
|
|
|
const File executableFile{TestHelper::getResourcesFolderLocation() + "app"};
|
|
|
@@ -89,7 +89,7 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, canRead_file_does_not_exist)
|
|
|
{
|
|
|
- File file{""};
|
|
|
+ const File file{""};
|
|
|
|
|
|
EXPECT_THROW(
|
|
|
{
|
|
|
@@ -118,7 +118,7 @@ namespace
|
|
|
ASSERT_FALSE(noWritableFile.canWrite());
|
|
|
#endif
|
|
|
#ifdef _WIN32
|
|
|
- File noWritableFile{TestHelper::getResourcesFolderLocation() + "no-writable-windows.txt"};
|
|
|
+ const File noWritableFile{TestHelper::getResourcesFolderLocation() + "no-writable-windows.txt"};
|
|
|
ASSERT_FALSE(noWritableFile.canWrite());
|
|
|
#endif
|
|
|
}
|
|
|
@@ -137,7 +137,7 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, createNewFile_file_does_already_exist)
|
|
|
{
|
|
|
- File file{TestHelper::getResourcesFolderLocation() + "simple.txt"};
|
|
|
+ const File file{TestHelper::getResourcesFolderLocation() + "simple.txt"};
|
|
|
|
|
|
EXPECT_THROW(
|
|
|
{
|
|
|
@@ -147,8 +147,8 @@ namespace
|
|
|
}
|
|
|
catch (const FileOperationException &_exception)
|
|
|
{
|
|
|
- string expected = _exception.getName() + R"lit( thrown - file ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(simple.txt" could not be created!)lit";
|
|
|
- string actual = _exception.what();
|
|
|
+ const string expected = _exception.getName() + R"lit( thrown - file ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(simple.txt" could not be created!)lit";
|
|
|
+ const string actual = _exception.what();
|
|
|
|
|
|
ASSERT_STREQ(expected.c_str(), actual.c_str());
|
|
|
throw;
|
|
|
@@ -174,13 +174,13 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, getAbsoluteFilePath)
|
|
|
{
|
|
|
- File file{this->fileLocation};
|
|
|
+ const File file{this->fileLocation};
|
|
|
ASSERT_STREQ(this->fileLocation.c_str(), file.getAbsoluteFilePath().c_str());
|
|
|
string s = {FilePathSeparator::get()};
|
|
|
|
|
|
- string wrongFilePath = "home" + s + s + s + "user" + s + "bla" + s + s + "sub_folder";
|
|
|
- string expectedFilePath = "home" + s + "user" + s + "bla" + s + "sub_folder";
|
|
|
- File anotherFile{wrongFilePath};
|
|
|
+ const string wrongFilePath = "home" + s + s + s + "user" + s + "bla" + s + s + "sub_folder";
|
|
|
+ const string expectedFilePath = "home" + s + "user" + s + "bla" + s + "sub_folder";
|
|
|
+ const File anotherFile{wrongFilePath};
|
|
|
ASSERT_STREQ(expectedFilePath.c_str(), anotherFile.getAbsoluteFilePath().c_str());
|
|
|
}
|
|
|
|
|
|
@@ -254,8 +254,8 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, list)
|
|
|
{
|
|
|
- File file{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
- list<string> filesInDirectory = file.list();
|
|
|
+ const File file{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
+ const list<string> filesInDirectory = file.list();
|
|
|
string expectedFile{};
|
|
|
const char separator = FilePathSeparator::get();
|
|
|
|
|
|
@@ -280,8 +280,8 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, listFiles)
|
|
|
{
|
|
|
- File file{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
- list<string> filesInDirectory = file.listFiles();
|
|
|
+ const File file{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
+ const list<string> filesInDirectory = file.listFiles();
|
|
|
string expectedFile{};
|
|
|
const char separator = FilePathSeparator::get();
|
|
|
|
|
|
@@ -312,7 +312,7 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, makeDirectory_directory_already_exists)
|
|
|
{
|
|
|
- File directory{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
+ const File directory{TestHelper::getResourcesFolderLocation() + "list-test"};
|
|
|
|
|
|
EXPECT_THROW(
|
|
|
{
|
|
|
@@ -322,8 +322,8 @@ namespace
|
|
|
}
|
|
|
catch (const FileOperationException &_exception)
|
|
|
{
|
|
|
- string expected = _exception.getName() + R"lit( thrown - directory ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(list-test" could not be created!)lit";
|
|
|
- string actual = _exception.what();
|
|
|
+ const string expected = _exception.getName() + R"lit( thrown - directory ")lit" + TestHelper::getResourcesFolderLocation() + R"lit(list-test" could not be created!)lit";
|
|
|
+ const string actual = _exception.what();
|
|
|
|
|
|
ASSERT_STREQ(expected.c_str(), actual.c_str());
|
|
|
throw;
|
|
|
@@ -365,8 +365,8 @@ namespace
|
|
|
|
|
|
TEST_F(FileTest, renameTo)
|
|
|
{
|
|
|
- string currentName = TestHelper::getResourcesFolderLocation() + "tmp-rename-to.txt";
|
|
|
- string newName = TestHelper::getResourcesFolderLocation() + "tmp-rename-to-better-name.txt";
|
|
|
+ const string currentName = TestHelper::getResourcesFolderLocation() + "tmp-rename-to.txt";
|
|
|
+ const string newName = TestHelper::getResourcesFolderLocation() + "tmp-rename-to-better-name.txt";
|
|
|
|
|
|
File file{currentName};
|
|
|
file.createNewFile();
|