From 0c743558120d3906a508ce5d4061b9f12972ea78 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Thu, 20 Nov 2014 16:55:51 +0100 Subject: [PATCH] Use parametrized test for FuseLstatErrorTest --- .../fspp/fuse/lstat/FuseLstatErrorTest.cpp | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp b/src/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp index 99481302..da7a9294 100644 --- a/src/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp +++ b/src/test/fspp/fuse/lstat/FuseLstatErrorTest.cpp @@ -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 { 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); }