Skip to content

Commit

Permalink
refactor: Inlined methods in base_fs
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed May 6, 2024
1 parent 7c437fb commit cfba248
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 54 deletions.
57 changes: 24 additions & 33 deletions test/testutil/storage/base_fs_test.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@


#include "testutil/storage/base_fs_test.hpp"

namespace test {
namespace test
{

void BaseFS_Test::clear() {
if (fs::exists(base_path)) {
fs::remove_all(base_path);
void BaseFS_Test::clear()
{
if ( fs::exists( base_path ) )
{
fs::remove_all( base_path );
}
}
}

void BaseFS_Test::mkdir() {
fs::create_directory(base_path);
}

std::string BaseFS_Test::getPathString() const {
return fs::canonical(base_path).string();
}

BaseFS_Test::~BaseFS_Test() {
clear();
}
BaseFS_Test::BaseFS_Test( fs::path path ) : base_path( std::move( path ) )
{
clear();
mkdir();

BaseFS_Test::BaseFS_Test(fs::path path) : base_path(std::move(path)) {
clear();
mkdir();

logger = sgns::base::createLogger(getPathString());
logger->set_level(spdlog::level::debug);
}
logger = sgns::base::createLogger( getPathString() );
logger->set_level( spdlog::level::debug );
}

void BaseFS_Test::SetUp() {
clear();
mkdir();
}
void BaseFS_Test::SetUp()
{
clear();
mkdir();
}

void BaseFS_Test::TearDown() {
clear();
}
} // namespace test
void BaseFS_Test::TearDown()
{
}
}
49 changes: 28 additions & 21 deletions test/testutil/storage/base_fs_test.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#ifndef SUPERGENIUS_BASE_FS_TEST_HPP
#define SUPERGENIUS_BASE_FS_TEST_HPP

Expand All @@ -11,33 +9,42 @@
// intentionally here, so users can use fs shortcut
namespace fs = boost::filesystem;

namespace test {

/**
namespace test
{
/**
* @brief Base test, which involves filesystem. Can be created with given
* path. Clears path before test and after test.
*/
struct BaseFS_Test : public ::testing::Test {
// not explicit, intentionally
BaseFS_Test(fs::path path);

void clear();
struct BaseFS_Test : public ::testing::Test
{
// not explicit, intentionally
BaseFS_Test( fs::path path );

void mkdir();
~BaseFS_Test() override
{
clear();
}

std::string getPathString() const;
void clear();

~BaseFS_Test() override;
inline void mkdir()
{
fs::create_directory( base_path );
}

void TearDown() override;
[[nodiscard]] std::string getPathString() const
{
return fs::canonical( base_path ).string();
}

void SetUp() override;
void TearDown() override;

protected:
fs::path base_path;
sgns::base::Logger logger;
};
void SetUp() override;

} // namespace test
protected:
fs::path base_path;
sgns::base::Logger logger;
};
}

#endif // SUPERGENIUS_BASE_FS_TEST_HPP
#endif

0 comments on commit cfba248

Please sign in to comment.