| @@ -46,6 +46,13 @@ namespace sr | |||
| { | |||
| public: | |||
| unique_resource() | |||
| : resource(R{}, scope_exit{[] { }}), | |||
| deleter(D{}, scope_exit{[] { }}), | |||
| execute_on_reset(false) | |||
| { | |||
| } | |||
| template<class RR, class DD, | |||
| std::enable_if_t<(std::is_constructible_v<R ,RR> && std::is_constructible_v<D, DD> | |||
| && (std::is_nothrow_constructible_v<R, RR> || std::is_constructible_v<R, RR&>) | |||
| @@ -37,6 +37,19 @@ namespace mock | |||
| }; | |||
| struct MoveableMock | |||
| { | |||
| static constexpr bool trompeloeil_movable_mock = true; | |||
| MAKE_CONST_MOCK1(deleter, void(Handle)); | |||
| void operator()(Handle h) const | |||
| { | |||
| this->deleter(h); | |||
| } | |||
| }; | |||
| struct ThrowOnCopyMock | |||
| { | |||
| ThrowOnCopyMock() | |||
| @@ -38,6 +38,11 @@ namespace | |||
| } | |||
| } | |||
| TEST_CASE("default construction", "[UniqueResource]") | |||
| { | |||
| sr::unique_resource<int, MoveableMock> guard{}; | |||
| } | |||
| TEST_CASE("construction with move", "[UniqueResource]") | |||
| { | |||
| REQUIRE_CALL(m, deleter(3)); | |||