Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-rtos mbed HardwareInterface
Fork of NerfUS_cmake_cleanup by
test/GoogleMockTest.cpp
- Committer:
- Maxime Dupuis
- Date:
- 2017-02-04
- Revision:
- 3:aaf84424abb1
File content as of revision 3:aaf84424abb1:
#include "gmock/gmock.h"
#include "gtest/gtest.h"
class Adder
{
public:
virtual ~Adder() {}
virtual int add(int a, int b)
{
return a + b;
}
};
class MockAdder : public Adder
{
public:
MOCK_METHOD2(add, int(int a, int b));
};
TEST(GoogleMockTest, ExpectCalled)
{
MockAdder adder;
EXPECT_CALL(adder, add(1, 2));
adder.add(1, 2);
}
TEST(GoogleMockTest, DefineReturnedValue)
{
using ::testing::Return;
MockAdder adder;
EXPECT_CALL(adder, add(1, 2))
.WillOnce(Return(42));
ASSERT_EQ(42, adder.add(1, 2));
}
