| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "SharedCloneable.hpp" | ||
| 2 | |||
| 3 | #include "Verbose.hpp" | ||
| 4 | #include "compat/gsl14.hpp" | ||
| 5 | #include <gtest/gtest.h> | ||
| 6 | #include <vector> | ||
| 7 | |||
| 8 | // SharedCloneable enforces non-copyability. | ||
| 9 | // NOLINTNEXTLINE *-special-member-functions | ||
| 10 | class ConcreteObject : public SharedCloneable<ConcreteObject> { | ||
| 11 | public: // pseudo-protected | ||
| 12 | 1 | ConcreteObject(Protected) : ConcreteObject{} {} | |
| 13 | 1 | ConcreteObject(Protected, const ConcreteObject& other) : | |
| 14 | 1 | ConcreteObject{other} {} | |
| 15 | |||
| 16 | protected: | ||
| 17 | 2 | ConcreteObject() = default; | |
| 18 | 2 | ConcreteObject(const ConcreteObject&) = default; | |
| 19 | }; | ||
| 20 | |||
| 21 | // SharedCloneable enforces non-copyability. | ||
| 22 | // NOLINTNEXTLINE *-special-member-functions | ||
| 23 | class DerivedObject : public SharedCloneable<DerivedObject, ConcreteObject> { | ||
| 24 | public: // pseudo-protected | ||
| 25 | 1 | DerivedObject(Protected) : DerivedObject{} {} | |
| 26 | 1 | DerivedObject(Protected, const DerivedObject& other) : | |
| 27 | 1 | DerivedObject{other} {} | |
| 28 | |||
| 29 | protected: | ||
| 30 | 1 | DerivedObject() = default; | |
| 31 | 1 | DerivedObject(const DerivedObject&) = default; | |
| 32 | }; | ||
| 33 | |||
| 34 | 8 | TEST(SharedCloneable, clone) { | |
| 35 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
6 | auto p1 = make_verbose("concrete", create<ConcreteObject>()); |
| 36 |
1/2✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
2 | auto p2 = p1->shared_from_this(); // copy of pointer |
| 37 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | auto p3 = p1->clone(); |
| 38 |
3/6✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
6 | auto p4 = make_verbose("derived", create<DerivedObject>()); |
| 39 |
1/2✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | auto p5 = p4->clone(); |
| 40 | 4 | } | |
| 41 |