#pragma once #ifndef MESSMER_FSPP_FSTEST_TESTUTILS_FILESYSTEMTEST_H_ #define MESSMER_FSPP_FSTEST_TESTUTILS_FILESYSTEMTEST_H_ #include #include #include #include #include #include "../../fs_interface/Device.h" #include "../../fs_interface/Dir.h" #include "../../fs_interface/File.h" #include "../../fs_interface/OpenFile.h" class FileSystemTestFixture { public: virtual ~FileSystemTestFixture() {} virtual cpputils::unique_ref createDevice() = 0; }; template class FileSystemTest: public ::testing::Test { public: BOOST_STATIC_ASSERT_MSG( (std::is_base_of::value), "Given test fixture for instantiating the (type parameterized) FileSystemTest must inherit from FileSystemTestFixture" ); FileSystemTest(): fixture(), device(fixture.createDevice()) {} ConcreteFileSystemTestFixture fixture; cpputils::unique_ref device; static constexpr mode_t MODE_PUBLIC = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH; cpputils::unique_ref LoadDir(const boost::filesystem::path &path) { auto loaded = device->Load(path); EXPECT_NE(boost::none, loaded); auto dir = cpputils::dynamic_pointer_move(*loaded); EXPECT_NE(boost::none, dir); return std::move(*dir); } cpputils::unique_ref LoadFile(const boost::filesystem::path &path) { auto loaded = device->Load(path); EXPECT_NE(boost::none, loaded); auto file = cpputils::dynamic_pointer_move(*loaded); EXPECT_NE(boost::none, file); return std::move(*file); } }; #endif