BoosterSeat  0.1
A C++ library that includes common utilities that are used in other projects.
filesystem_test.cpp File Reference
#include <BoosterSeat/exception.hpp>
#include <BoosterSeat/filesystem.hpp>
#include <BoosterSeat/numbers.hpp>
#include "gtest/gtest.h"
#include <filesystem>
#include <fstream>
#include <sstream>
Include dependency graph for filesystem_test.cpp:

Macros

#define NO_PERM_CHECKS
 

Functions

void createFileOfSizeMb (const std::string file_path, const int file_size_mb)
 
 TEST (bst_filesystem, appendToFile)
 
 TEST (bst_filesystem, copyFile)
 
 TEST (bst_filesystem, createFile)
 
 TEST (bst_filesystem, deleteFile)
 
 TEST (bst_filesystem, directorySize)
 
 TEST (bst_filesystem, doesDirectoryExist_createDirectory)
 
 TEST (bst_filesystem, doesFileExist)
 
 TEST (bst_filesystem, getFileName)
 
 TEST (bst_filesystem, getFileSize)
 
 TEST (bst_filesystem, hasReadPermission)
 
 TEST (bst_filesystem, hasWritePermission)
 
 TEST (bst_filesystem, moveFileTest)
 
 TEST (bst_filesystem, NO_PERM_hasWritePermission)
 
 TEST (bst_filesystem, overwriteFile)
 
void validateSize (const double size, const double expected_size)
 

Macro Definition Documentation

◆ NO_PERM_CHECKS

#define NO_PERM_CHECKS

Manually need to create files/directories for "NO_PERM_CHECKS".

In the same directory as the executable, create the following with no read/write permissions for the user: ./perm_test_dir ./perm_test_dir/perm_test_file.txt

Function Documentation

◆ createFileOfSizeMb()

void createFileOfSizeMb ( const std::string  file_path,
const int  file_size_mb 
)
inline

Referenced by TEST().

Here is the caller graph for this function:

◆ TEST() [1/14]

TEST ( bst_filesystem  ,
doesFileExist   
)

References bst::filesystem::doesFileExist(), bst::BoosterSeatException::errorNumberEnum(), and bst::FS_PATH_NOT_REGULAR_FILE.

Here is the call graph for this function:

◆ TEST() [2/14]

TEST ( bst_filesystem  ,
createFile   
)

References bst::filesystem::createFile(), bst::filesystem::doesFileExist(), bst::BoosterSeatException::errorNumberEnum(), bst::fs_int::exists(), and bst::FS_PATH_ALREADY_EXISTS.

Here is the call graph for this function:

◆ TEST() [3/14]

TEST ( bst_filesystem  ,
appendToFile   
)

References bst::filesystem::appendToFile(), bst::BoosterSeatException::errorNumberEnum(), and bst::FS_PATH_DOES_NOT_EXIST.

Here is the call graph for this function:

◆ TEST() [4/14]

TEST ( bst_filesystem  ,
overwriteFile   
)

References bst::BoosterSeatException::errorNumberEnum(), bst::FS_PATH_DOES_NOT_EXIST, and bst::filesystem::overwriteFile().

Here is the call graph for this function:

◆ validateSize()

void validateSize ( const double  size,
const double  expected_size 
)
inline

References bst::isApproxEqualPercent().

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TEST() [5/14]

TEST ( bst_filesystem  ,
getFileSize   
)

References createFileOfSizeMb(), bst::filesystem::getFileSize(), and validateSize().

Here is the call graph for this function:

◆ TEST() [6/14]

TEST ( bst_filesystem  ,
deleteFile   
)

References bst::filesystem::deleteFile(), bst::filesystem::doesFileExist(), bst::BoosterSeatException::errorNumberEnum(), and bst::FS_PATH_DOES_NOT_EXIST.

Here is the call graph for this function:

◆ TEST() [7/14]

TEST ( bst_filesystem  ,
doesDirectoryExist_createDirectory   
)

References bst::filesystem::createDirectory(), bst::filesystem::doesDirectoryExist(), bst::filesystem::doesFileExist(), bst::BoosterSeatException::errorNumberEnum(), bst::fs_int::exists(), and bst::FS_PATH_NOT_DIRECTORY.

Here is the call graph for this function:

◆ TEST() [8/14]

TEST ( bst_filesystem  ,
directorySize   
)

References bst::filesystem::createDirectory(), createFileOfSizeMb(), bst::fs_int::exists(), bst::filesystem::getDirectorySize(), and validateSize().

Here is the call graph for this function:

◆ TEST() [9/14]

TEST ( bst_filesystem  ,
hasWritePermission   
)

References bst::filesystem::hasWritePermission().

Here is the call graph for this function:

◆ TEST() [10/14]

TEST ( bst_filesystem  ,
hasReadPermission   
)

References bst::filesystem::hasReadPermission().

Here is the call graph for this function:

◆ TEST() [11/14]

TEST ( bst_filesystem  ,
NO_PERM_hasWritePermission   
)

References bst::filesystem::hasWritePermission().

Here is the call graph for this function:

◆ TEST() [12/14]

TEST ( bst_filesystem  ,
moveFileTest   
)

References bst::filesystem::createDirectory(), bst::filesystem::doesFileExist(), bst::fs_int::exists(), and bst::filesystem::moveFile().

Here is the call graph for this function:

◆ TEST() [13/14]

TEST ( bst_filesystem  ,
getFileName   
)

References bst::filesystem::getFileName().

Here is the call graph for this function:

◆ TEST() [14/14]

TEST ( bst_filesystem  ,
copyFile   
)
Todo:
Missing test coverage: Next append the source file with content so it's size is different from the destination file. Then perform the tests below and compare the file sizes.

References bst::filesystem::appendToFile(), bst::filesystem::copyFile(), bst::filesystem::createFile(), bst::filesystem::doesFileExist(), bst::BoosterSeatException::errorNumberEnum(), bst::fs_int::exists(), bst::FS_PATH_ALREADY_EXISTS, and bst::filesystem::getFileSizeBytes().

Here is the call graph for this function: