Merge branch 'develop' into next

This commit is contained in:
Sebastian Messmer 2017-01-22 01:11:36 +00:00
commit af24fa5402
2 changed files with 22 additions and 60 deletions

View File

@ -19,7 +19,7 @@ public:
// Test cases only run for file nodes
template<class ConcreteFileSystemTestFixture>
class FsppNodeTest_Stat_FileOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTest_File_Helper {};
class FsppNodeTest_Stat_FileOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
TYPED_TEST_CASE_P(FsppNodeTest_Stat_FileOnly);
@ -39,7 +39,7 @@ TYPED_TEST_P(FsppNodeTest_Stat_FileOnly, FileIsFile) {
// Test cases only run for dir nodes
template<class ConcreteFileSystemTestFixture>
class FsppNodeTest_Stat_DirOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTest_Dir_Helper {};
class FsppNodeTest_Stat_DirOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
TYPED_TEST_CASE_P(FsppNodeTest_Stat_DirOnly);
@ -53,7 +53,7 @@ TYPED_TEST_P(FsppNodeTest_Stat_DirOnly, DirIsDir) {
// Test cases only run for symlink nodes
template<class ConcreteFileSystemTestFixture>
class FsppNodeTest_Stat_SymlinkOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTest_Symlink_Helper {};
class FsppNodeTest_Stat_SymlinkOnly: public FileSystemTest<ConcreteFileSystemTestFixture>, public FsppNodeTestHelper {};
TYPED_TEST_CASE_P(FsppNodeTest_Stat_SymlinkOnly);

View File

@ -7,12 +7,19 @@
#include <boost/preprocessor/variadic/to_seq.hpp>
#include <boost/preprocessor/seq/for_each.hpp>
// TODO separation into File/Dir/Symlink Helpers probably not needed anymore
class FsppNodeTestBase {
class FsppNodeTestHelper {
public:
virtual void IN_STAT(fspp::Node *node, std::function<void (struct stat)> callback) = 0;
virtual void EXPECT_SIZE(uint64_t expectedSize, fspp::Node *node) = 0;
void IN_STAT(fspp::Node *file, std::function<void (struct stat)> callback) {
struct stat st;
file->stat(&st);
callback(st);
}
void EXPECT_SIZE(uint64_t expectedSize, fspp::Node *node) {
IN_STAT(node, [expectedSize] (struct stat st) {
EXPECT_EQ(expectedSize, (uint64_t)st.st_size);
});
}
};
/**
@ -24,56 +31,11 @@ public:
* See FsppNodeTest_Rename for an example.
*/
template<class ConcreteFileSystemTestFixture>
class FsppNodeTest: public virtual FsppNodeTestBase, public virtual FileSystemTest<ConcreteFileSystemTestFixture> {
class FsppNodeTest: public virtual FsppNodeTestHelper, public virtual FileSystemTest<ConcreteFileSystemTestFixture> {
public:
virtual cpputils::unique_ref<fspp::Node> CreateNode(const boost::filesystem::path &path) = 0;
};
class FsppNodeTest_File_Helper: public virtual FsppNodeTestBase {
public:
void IN_STAT(fspp::Node *file, std::function<void (struct stat)> callback) override {
struct stat st;
file->stat(&st);
callback(st);
}
void EXPECT_SIZE(uint64_t expectedSize, fspp::Node *node) override {
IN_STAT(node, [expectedSize] (struct stat st) {
EXPECT_EQ(expectedSize, (uint64_t)st.st_size);
});
}
};
class FsppNodeTest_Dir_Helper: public virtual FsppNodeTestBase {
public:
void IN_STAT(fspp::Node *file, std::function<void (struct stat)> callback) override {
struct stat st;
file->stat(&st);
callback(st);
}
void EXPECT_SIZE(uint64_t expectedSize, fspp::Node *node) override {
IN_STAT(node, [expectedSize] (struct stat st) {
EXPECT_EQ(expectedSize, (uint64_t)st.st_size);
});
}
};
class FsppNodeTest_Symlink_Helper: public virtual FsppNodeTestBase {
public:
void IN_STAT(fspp::Node *file, std::function<void (struct stat)> callback) override {
struct stat st;
file->stat(&st);
callback(st);
}
void EXPECT_SIZE(uint64_t expectedSize, fspp::Node *node) override {
IN_STAT(node, [expectedSize] (struct stat st) {
EXPECT_EQ(expectedSize, (uint64_t)st.st_size);
});
}
};
#define _REGISTER_SINGLE_NODE_TEST_CASE(r, Class, Name) \
TYPED_TEST_P(Class, Name) { \
this->BOOST_PP_CAT(Test_,Name)(); \
@ -85,11 +47,11 @@ public:
#define _REGISTER_FILE_TEST_CASE(Class, ...) \
template<class ConcreteFileSystemTestFixture> \
class Class##_FileNode: public Class<ConcreteFileSystemTestFixture>, public FsppNodeTest_File_Helper { \
class Class##_FileNode: public Class<ConcreteFileSystemTestFixture>, public virtual FsppNodeTestHelper { \
public: \
cpputils::unique_ref<fspp::Node> CreateNode(const boost::filesystem::path &path) override { \
this->CreateFile(path); \
return this->Load(path); \
return this->Load(path); \
} \
}; \
TYPED_TEST_CASE_P(Class##_FileNode); \
@ -97,11 +59,11 @@ public:
#define _REGISTER_DIR_TEST_CASE(Class, ...) \
template<class ConcreteFileSystemTestFixture> \
class Class##_DirNode: public Class<ConcreteFileSystemTestFixture>, public FsppNodeTest_Dir_Helper { \
class Class##_DirNode: public Class<ConcreteFileSystemTestFixture>, public virtual FsppNodeTestHelper { \
public: \
cpputils::unique_ref<fspp::Node> CreateNode(const boost::filesystem::path &path) override { \
this->CreateDir(path); \
return this->Load(path); \
return this->Load(path); \
} \
}; \
TYPED_TEST_CASE_P(Class##_DirNode); \
@ -109,11 +71,11 @@ public:
#define _REGISTER_SYMLINK_TEST_CASE(Class, ...) \
template<class ConcreteFileSystemTestFixture> \
class Class##_SymlinkNode: public Class<ConcreteFileSystemTestFixture>, public FsppNodeTest_Symlink_Helper { \
class Class##_SymlinkNode: public Class<ConcreteFileSystemTestFixture>, public virtual FsppNodeTestHelper { \
public: \
cpputils::unique_ref<fspp::Node> CreateNode(const boost::filesystem::path &path) override { \
this->CreateSymlink(path); \
return this->Load(path); \
return this->Load(path); \
} \
}; \
TYPED_TEST_CASE_P(Class##_SymlinkNode); \