Skip to content

Commit

Permalink
Merge pull request #329 from eranpeer/fix-gcc-clang-warnings
Browse files Browse the repository at this point in the history
Fix GCC and Clang warnings on tests
  • Loading branch information
FranckRJ authored Apr 14, 2024
2 parents dc1dbd1 + a0e19c2 commit fa53ef2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 19 deletions.
13 changes: 1 addition & 12 deletions tests/default_behaviore_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,13 @@ struct DefaultBehavioreTests : tpunit::TestFixture {
public:
virtual ~ISomeInterface3() {
int a = 0;
(void)a;
a++;
}

virtual void methodWithSomeSharedPointer(std::shared_ptr<ISomeInterface3> listener) = 0;
};

// void production_shared_ptr_mock_used_in_invocation() {
// std::shared_ptr<ISomeInterface3> pMockInstance;
// Mock<ISomeInterface3> mock;
// fakeit::Fake(Dtor(mock));
// fakeit::Fake(Method(mock, methodWithSomeSharedPointer));
//
// pMockInstance = mock.getShared();
// pMockInstance->methodWithSomeSharedPointer(pMockInstance);
//
// pMockInstance = nullptr;
// }

void production_shared_ptr_mock_used_in_invocation() {
Mock<ISomeInterface3> mock;
std::shared_ptr<ISomeInterface3> pMockInstance(&mock.get());
Expand Down
4 changes: 2 additions & 2 deletions tests/move_only_return_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ struct MoveOnlyReturnTests: tpunit::TestFixture {

class AbstractType {
public:
virtual ~AbstractType() = default;
virtual void foo() = 0;
};

class ConcreteType: public AbstractType {
class ConcreteType : public AbstractType {
public:
int state;
ConcreteType(int value) :
Expand Down Expand Up @@ -84,4 +85,3 @@ struct MoveOnlyReturnTests: tpunit::TestFixture {
ASSERT_EQUAL(ConcreteType(10), i.returnMoveOnlyConcreteTypeByRef());
}
} __MoveOnlyReturnTests;

4 changes: 4 additions & 0 deletions tests/remove_const_volatile_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ struct RemoveConstVolatileTests : tpunit::TestFixture {
}

struct ConstVolatileParameters{
#if FAKEIT_CPLUSPLUS >= 202002L
virtual int func1(const int a, const std::string s) = 0;
#else
virtual int func1(const int a, const volatile std::string s) = 0;
#endif
};

void TestConstParameters()
Expand Down
7 changes: 7 additions & 0 deletions tests/rvalue_arguments_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ struct RValueTypesTests : tpunit::TestFixture {

using CompositeType = std::pair < int, int > ;

#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 13
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#endif
struct RValueInterface {
virtual int intRValueArg(int&&) = 0;
virtual int compositeRValueArg(CompositeType&&) = 0;
Expand All @@ -36,6 +40,9 @@ struct RValueTypesTests : tpunit::TestFixture {
virtual RValueInterface& operator=(RValueInterface&&) = 0;
virtual RValueInterface& operator=(const RValueInterface&) = 0;
};
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 13
#pragma GCC diagnostic pop
#endif

RValueTypesTests() :
TestFixture(
Expand Down
3 changes: 2 additions & 1 deletion tests/type_info_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct TypeInfoTests : tpunit::TestFixture {

void mock_should_use_same_typeid_as_mocked_class() {
Mock<SomeInterface> mock;
ASSERT_EQUAL(typeid(mock.get()), typeid(SomeInterface));
auto& mockRef = mock.get();
ASSERT_EQUAL(typeid(mockRef), typeid(SomeInterface));
}

struct ConcreteType {
Expand Down
8 changes: 4 additions & 4 deletions tests/verification_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ struct BasicVerification: tpunit::TestFixture {
{
try {
const auto a = VerifyNoOtherInvocations(Method(mock,func));
if (&a == &a) // use a to avoid unused variable compilation warning.
throw std::runtime_error("some exception");
(void)a; // use a to avoid unused variable compilation warning.
throw std::runtime_error("some exception");
} catch (std::runtime_error &) {
}
}
Expand All @@ -405,8 +405,8 @@ struct BasicVerification: tpunit::TestFixture {
try {
const auto a = Verify(Method(mock,func));
//const auto b = Verify(Method(mock, func)).Exactly(1);
if (&a == &a) // use a to avoid unused variable compilation warning.
throw std::runtime_error("some exception");
(void)a; // use a to avoid unused variable compilation warning.
throw std::runtime_error("some exception");
} catch (std::runtime_error &) {
}
}
Expand Down

0 comments on commit fa53ef2

Please sign in to comment.