mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-29 06:12:18 -06:00
.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:
parent
e6c6cb6d8c
commit
eee6bc3fb5
3 changed files with 47 additions and 1 deletions
39
bazaar/GoogleMockExample/GoogleMockExample.cpp
Normal file
39
bazaar/GoogleMockExample/GoogleMockExample.cpp
Normal 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue