Implement ReturnIsFileStat action

This commit is contained in:
Sebastian Messmer 2014-11-19 00:38:41 +01:00
parent 205f93531f
commit 988c9b4307
2 changed files with 8 additions and 3 deletions

View File

@ -35,9 +35,7 @@ TEST_F(FuseTest, setupAndTearDown) {
TEST_F(FuseTest, openFile) {
const char *filename = "/myfile";
EXPECT_CALL(fsimpl, lstat(StrEq(filename), _)).WillOnce(Invoke([](const char*, struct ::stat* result) {
result->st_mode = S_IFREG;
}));
EXPECT_CALL(fsimpl, lstat(StrEq(filename), _)).WillOnce(ReturnIsFileStat);
EXPECT_CALL(fsimpl, openFile(StrEq(filename), OpenFlagsEq(O_RDWR)))
.Times(1);

View File

@ -118,10 +118,17 @@ public:
}
MockFilesystem fsimpl;
static ::testing::Action<void(const char*, struct ::stat*)> ReturnIsFileStat;
};
MATCHER_P(OpenFlagsEq, expectedFlags, "") {
return expectedFlags == (O_ACCMODE & arg);
}
::testing::Action<void(const char*, struct ::stat*)> FuseTest::ReturnIsFileStat =
::testing::Invoke([](const char*, struct ::stat* result) {
result->st_mode = S_IFREG;
});
#endif