Simplify using OpenFlagsEq matcher

This commit is contained in:
Sebastian Messmer 2014-11-19 00:31:47 +01:00
parent ffee279c5a
commit 205f93531f
2 changed files with 7 additions and 7 deletions

View File

@ -35,15 +35,11 @@ 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) {
EXPECT_CALL(fsimpl, lstat(StrEq(filename), _)).WillOnce(Invoke([](const char*, struct ::stat* result) {
result->st_mode = S_IFREG;
}));
EXPECT_CALL(fsimpl, openFile(StrEq(filename), _))
.WillOnce(Invoke([](const char*, int flags) {
EXPECT_EQ(O_RDWR, O_ACCMODE & flags);
return 0;
}));
EXPECT_CALL(fsimpl, openFile(StrEq(filename), OpenFlagsEq(O_RDWR)))
.Times(1);
auto fs = TestFS();

View File

@ -120,4 +120,8 @@ public:
MockFilesystem fsimpl;
};
MATCHER_P(OpenFlagsEq, expectedFlags, "") {
return expectedFlags == (O_ACCMODE & arg);
}
#endif