Skip to content

Commit

Permalink
Added tests that should fail on MSVC.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed Jun 2, 2024
1 parent 8a66729 commit 7adf1db
Showing 1 changed file with 39 additions and 10 deletions.
49 changes: 39 additions & 10 deletions tests/inherited_funcs_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,44 @@ struct InheritedFuncsTests : tpunit::TestFixture

InheritedFuncsTests() :
TestFixture(
TEST(InheritedFuncsTests::mock_base_overloaded_functions),
TEST(InheritedFuncsTests::mock_base_and_child_overloaded_functions)
TEST(InheritedFuncsTests::mock_super_base_overloaded_functions),
TEST(InheritedFuncsTests::mock_super_base_and_base_overloaded_functions),
TEST(InheritedFuncsTests::mock_super_base_and_child_overloaded_functions)
)
{
}

class BaseInterface
class SuperBaseInterface
{
public:
virtual ~BaseInterface() = default;
virtual ~SuperBaseInterface() = default;

virtual double nonOverloadedMethod() = 0;
virtual double overloadedMethod() = 0;
virtual double overloadedMethod() const = 0;
virtual double overloadedInBaseMethod() = 0;
virtual double overloadedInChildMethod() = 0;
};

class BaseInterface : public SuperBaseInterface
{
public:
~BaseInterface() override = default;

using SuperBaseInterface::overloadedInBaseMethod;
virtual double overloadedInBaseMethod() const = 0;
};

class Interface : public BaseInterface
{
public:
~Interface() override = default;

using BaseInterface::overloadedInChildMethod;
virtual double overloadedInChildMethod() const = 0;
};

void mock_base_overloaded_functions()
void mock_super_base_overloaded_functions()
{
Mock<Interface> mock;

Expand All @@ -61,18 +73,35 @@ struct InheritedFuncsTests : tpunit::TestFixture
Verify(ConstOverloadedMethod(mock, overloadedMethod, double())).Exactly(1);
}

void mock_base_and_child_overloaded_functions()
void mock_super_base_and_base_overloaded_functions()
{
Mock<Interface> mock;

When(OverloadedMethod(mock, overloadedInBaseMethod, double())).Return(4.5);
When(ConstOverloadedMethod(mock, overloadedInBaseMethod, double())).Return(5.5);

Interface& interface = mock.get();
const Interface& constInterface = mock.get();

EXPECT_EQUAL(interface.overloadedInBaseMethod(), 4.5);
EXPECT_EQUAL(constInterface.overloadedInBaseMethod(), 5.5);

Verify(OverloadedMethod(mock, overloadedInBaseMethod, double())).Exactly(1);
Verify(ConstOverloadedMethod(mock, overloadedInBaseMethod, double())).Exactly(1);
}

void mock_super_base_and_child_overloaded_functions()
{
Mock<Interface> mock;

When(OverloadedMethod(mock, overloadedInChildMethod, double())).Return(4.5);
When(ConstOverloadedMethod(mock, overloadedInChildMethod, double())).Return(5.5);
When(OverloadedMethod(mock, overloadedInChildMethod, double())).Return(6.5);
When(ConstOverloadedMethod(mock, overloadedInChildMethod, double())).Return(7.5);

Interface& interface = mock.get();
const Interface& constInterface = mock.get();

EXPECT_EQUAL(interface.overloadedInChildMethod(), 4.5);
EXPECT_EQUAL(constInterface.overloadedInChildMethod(), 5.5);
EXPECT_EQUAL(interface.overloadedInChildMethod(), 6.5);
EXPECT_EQUAL(constInterface.overloadedInChildMethod(), 7.5);

Verify(OverloadedMethod(mock, overloadedInChildMethod, double())).Exactly(1);
Verify(ConstOverloadedMethod(mock, overloadedInChildMethod, double())).Exactly(1);
Expand Down

0 comments on commit 7adf1db

Please sign in to comment.