|
101 | 101 | };
|
102 | 102 | ```
|
103 | 103 | ```cpp
|
104 |
| - Google.Test | GUnit.GMake |
105 |
| - ------------------------------------------+-------------------------------------------------- |
106 |
| - #include <gtest/gtest.h> | #include <GUnit.h> |
107 |
| - #include <gmock/gmock.h> | |
108 |
| - | |
109 |
| - TEST(CalcTest, ShouldMakeCoffee) { | GTEST("Calc Test") { |
110 |
| - StrictMock<mock_heater> heater{}; | auto [sut, mocks] = |
111 |
| - StrictMock<mock_pump> pump{}; | make<coffee_maker, StrictGMock>(); |
112 |
| - StrictMock<mock_grinder> grinder{}; | |
113 |
| - coffee_maker sut{heater, pump, grinder};| EXPECT_CALL(mocks.mock<iheater>(), (on)()); |
114 |
| - | EXPECT_CALL(mocks.mock<ipump>(), (pump)()); |
115 |
| - EXPECT_CALL(heater, on()); | EXPECT_CALL(mocks.mock<igrinder>(), (grind)()); |
116 |
| - EXPECT_CALL(pump, pump()); | EXPECT_CALL(mocks.mock<iheater>(), (off)()); |
117 |
| - EXPECT_CALL(grinder, grind()); | |
118 |
| - EXPECT_CALL(heater, off()); | sut->brew(); |
119 |
| - | } |
120 |
| - sut->brew(); | |
| 104 | + Google.Test | GUnit.GMake |
| 105 | + ----------------------------------------+-------------------------------------------------- |
| 106 | + #include <gtest/gtest.h> | #include <GUnit.h> |
| 107 | + #include <gmock/gmock.h> | |
| 108 | + | |
| 109 | + TEST(CalcTest, ShouldMakeCoffee) { | GTEST("Calc Test") { |
| 110 | + StrictMock<mock_heater> heater{}; | auto [sut, mocks] = |
| 111 | + StrictMock<mock_pump> pump{}; | make<coffee_maker, StrictGMock>(); |
| 112 | + StrictMock<mock_grinder> grinder{}; | |
| 113 | + coffee_maker sut{heater,pump,grinder};| EXPECT_CALL(mocks.mock<iheater>(), (on)()); |
| 114 | + | EXPECT_CALL(mocks.mock<ipump>(), (pump)()); |
| 115 | + EXPECT_CALL(heater, on()); | EXPECT_CALL(mocks.mock<igrinder>(), (grind)()); |
| 116 | + EXPECT_CALL(pump, pump()); | EXPECT_CALL(mocks.mock<iheater>(), (off)()); |
| 117 | + EXPECT_CALL(grinder, grind()); | |
| 118 | + EXPECT_CALL(heater, off()); | sut->brew(); |
| 119 | + | } |
| 120 | + sut->brew(); | |
121 | 121 | }
|
122 | 122 | ```
|
123 | 123 |
|
|
0 commit comments