.bazaar Added Google Mock simply example

git-svn-id: svn://ultimatepp.org/upp/trunk@10859 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
klugier 2017-02-18 23:26:57 +00:00
parent e6c6cb6d8c
commit eee6bc3fb5
3 changed files with 47 additions and 1 deletions

View file

@ -0,0 +1,39 @@
#include <Core/Core.h>
#include <plugin/gmock/gmock.h>
using namespace Upp;
class Car {
public:
virtual ~Car() {}
virtual void OpenHood() = 0;
};
class MockCar : public Car {
public:
MOCK_METHOD0(OpenHood, void());
};
class CarRepairShop final {
public:
bool Service(Car& car) {
car.OpenHood();
}
};
TEST(CarRepairShopTest, ServiceChecksAllMainCarElements) {
MockCar car;
EXPECT_CALL(car, OpenHood())
.Times(::testing::AtLeast(1));
CarRepairShop().Service(car);
}
int main(int argc, char *argv[])
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}