| @@ -111,7 +111,7 @@ namespace sr | |||
| } | |||
| else | |||
| { | |||
| m_resource = std::as_const(r); | |||
| m_resource.reset(std::as_const(r)); | |||
| } | |||
| m_execute_on_destruction = true; | |||
| @@ -138,9 +138,31 @@ namespace mock | |||
| }; | |||
| struct NotNothrowAssignable | |||
| { | |||
| explicit NotNothrowAssignable(int value) : m_value(value) { } | |||
| NotNothrowAssignable(const NotNothrowAssignable&) = default; | |||
| NotNothrowAssignable& operator=(const NotNothrowAssignable& other) | |||
| { | |||
| if( this != &other ) | |||
| { | |||
| assignNotNoexcept(other.m_value); | |||
| } | |||
| return *this; | |||
| } | |||
| void assignNotNoexcept(int value) noexcept(false) | |||
| { | |||
| m_value = value; | |||
| } | |||
| int m_value; | |||
| }; | |||
| struct CopyMock | |||
| { | |||
| CopyMock() {} | |||
| CopyMock() { } | |||
| CopyMock(const CopyMock&) { } | |||
| }; | |||
| @@ -132,8 +132,9 @@ TEST_CASE("reset sets new lvalue and calls deleter on previous", "[UniqueResourc | |||
| { | |||
| REQUIRE_CALL(m, deleter(3)); | |||
| REQUIRE_CALL(m, deleter(7)); | |||
| auto guard = sr::unique_resource{Handle{3}, deleter}; | |||
| const Handle h{7}; | |||
| auto d = [](const auto& v) { deleter(v.m_value); }; | |||
| auto guard = sr::unique_resource{NotNothrowAssignable{3}, d}; | |||
| const NotNothrowAssignable h{7}; | |||
| guard.reset(h); | |||
| } | |||