Use parametrized test for FuseLstatErrorTest
This commit is contained in:
parent
0762c1dbde
commit
0c74355812
@ -5,15 +5,15 @@
|
||||
using ::testing::StrEq;
|
||||
using ::testing::_;
|
||||
using ::testing::Throw;
|
||||
using ::testing::WithParamInterface;
|
||||
using ::testing::Values;
|
||||
|
||||
using fspp::FuseErrnoException;
|
||||
|
||||
class FuseLstatErrorTest: public FuseLstatTest {
|
||||
class FuseLstatErrorTest: public FuseLstatTest, public WithParamInterface<int> {
|
||||
public:
|
||||
const int ERRCODE1 = EIO;
|
||||
const int ERRCODE2 = EACCES;
|
||||
const int ERRCODE3 = EBADF;
|
||||
};
|
||||
INSTANTIATE_TEST_CASE_P(LstatErrorCodes, FuseLstatErrorTest, Values(EACCES, EBADF, EFAULT, ELOOP, ENAMETOOLONG, ENOENT, ENOMEM, ENOTDIR, EOVERFLOW, EINVAL, ENOTDIR));
|
||||
|
||||
TEST_F(FuseLstatErrorTest, ReturnNoError) {
|
||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(ReturnIsFile);
|
||||
@ -21,23 +21,9 @@ TEST_F(FuseLstatErrorTest, ReturnNoError) {
|
||||
EXPECT_EQ(retval, 0);
|
||||
}
|
||||
|
||||
TEST_F(FuseLstatErrorTest, ReturnError2) {
|
||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(ERRCODE1)));
|
||||
TEST_P(FuseLstatErrorTest, ReturnError) {
|
||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(GetParam())));
|
||||
int retval = LstatPathAllowErrors(FILENAME);
|
||||
EXPECT_EQ(retval, -1);
|
||||
EXPECT_EQ(ERRCODE1, errno);
|
||||
}
|
||||
|
||||
TEST_F(FuseLstatErrorTest, ReturnError3) {
|
||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(ERRCODE2)));
|
||||
int retval = LstatPathAllowErrors(FILENAME);
|
||||
EXPECT_EQ(retval, -1);
|
||||
EXPECT_EQ(ERRCODE2, errno);
|
||||
}
|
||||
|
||||
TEST_F(FuseLstatErrorTest, ReturnError4) {
|
||||
EXPECT_CALL(fsimpl, lstat(StrEq(FILENAME), _)).Times(1).WillOnce(Throw(FuseErrnoException(ERRCODE3)));
|
||||
int retval = LstatPathAllowErrors(FILENAME);
|
||||
EXPECT_EQ(retval, -1);
|
||||
EXPECT_EQ(ERRCODE3, errno);
|
||||
EXPECT_EQ(GetParam(), errno);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user