|
72 | 72 | * Dependency Inversion Principle |
73 | 73 | * Automatic Mocks Injection |
74 | 74 | * TDD/BDD |
75 | | -* Showcase (User Story -> ... -> Commit) |
| 75 | +* Showcase |
76 | 76 | * C++2X... |
77 | 77 |
|
78 | 78 | ============================================================================== |
|
200 | 200 | ```cpp |
201 | 201 | GTEST("Can add numbers") { |
202 | 202 | // set-up |
203 | | - SHOULD("add 2 numbers") { EXPECT_EQ(4, add(2, 2)); } |
| 203 | + SHOULD("add 2 numbers") { EXPECT(4 == add(2, 2)); } |
204 | 204 | // tear-down |
205 | 205 | } |
206 | 206 | ``` |
|
365 | 365 | ```cpp |
366 | 366 | class MockReader { // no inheritance |
367 | 367 | public: |
368 | | - MOCK_CONST_METHOD1(read, int()); |
| 368 | + MOCK_CONST_METHOD0(read, int()); |
369 | 369 | }; |
370 | 370 | ``` |
371 | 371 |
|
|
1388 | 1388 |
|
1389 | 1389 | ============================================================================== |
1390 | 1390 |
|
1391 | | -## Showcase (User Story -> ... -> Commit) |
| 1391 | +## Showcase (User Story -> ... -> Merge Request) |
1392 | 1392 |
|
1393 | 1393 |  |
1394 | 1394 |
|
|
1752 | 1752 | #### Merged by a team member, only if: |
1753 | 1753 | * All code review dicussions were resolved |
1754 | 1754 | * All checks are passing |
1755 | | - * all tests/static,dynamic analysis, etc... |
| 1755 | + * All tests/static,dynamic analysis, etc... |
1756 | 1756 |
|
1757 | 1757 | ---- |
1758 | 1758 |
|
|
1806 | 1806 |
|
1807 | 1807 | ---- |
1808 | 1808 |
|
| 1809 | +### Static reflection - Mocks generation |
| 1810 | + |
| 1811 | +```cpp |
| 1812 | +template<class T> |
| 1813 | +$class GMock { |
| 1814 | +public: |
| 1815 | + virtual ~GMock() noexcept { } |
| 1816 | + constexpr { |
| 1817 | + for... (auto f: $GMock.functions()) { |
| 1818 | + f.make([] { fs...; }); |
| 1819 | + } |
| 1820 | + } |
| 1821 | +
|
| 1822 | +private: |
| 1823 | + flat_map<string, unique_ptr<UntypedFunctionMockerBase>> fs{}; |
| 1824 | +}; |
| 1825 | +``` |
| 1826 | + |
| 1827 | +---- |
| 1828 | + |
1809 | 1829 | ### Proposals |
1810 | 1830 |
|
1811 | 1831 | | | | |
1812 | 1832 | |-|-| |
1813 | | -| Mocks Generation | [(SG7) Static reflection](www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0194r0.pdf) | |
1814 | | -| Type constraints | [(SG8) Concepts lite](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3580.pdf) | |
1815 | | -| Concepts based type erasure | [Virtual Concepts](https://github.com/andyprowl/virtual-concepts/blob/master/draft/Dynamic%20Generic%20Programming%20with%20Virtual%20Concepts.pdf) | |
| 1833 | +| [(SG7) Static reflection](www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0194r0.pdf) | Mocks Generation | |
| 1834 | +| [(SG8) Concepts lite](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3580.pdf) | Type constraints | |
| 1835 | +| [Virtual Concepts](https://github.com/andyprowl/virtual-concepts/blob/master/draft/Dynamic%20Generic%20Programming%20with%20Virtual%20Concepts.pdf) | Concepts based type erasure | |
| 1836 | +| ? | Testing/Assertions | |
1816 | 1837 |
|
1817 | 1838 | ============================================================================== |
1818 | 1839 |
|
|
1825 | 1846 | * Consider using a good* testing framework |
1826 | 1847 | * Consider using a good* Mocking framework |
1827 | 1848 | * Consider writing `SOLID` instead of `STUPID` code |
1828 | | -* Consider using dependency injection framework |
| 1849 | +* Consider using dependency injection framework to avoid the wiring mess and inject mocks automatically |
1829 | 1850 | * Consider writing tests before the implementation |
1830 | 1851 |
|
1831 | 1852 | ---- |
|
0 commit comments