Browse Source

Method implemented.

main
offa 7 years ago
parent
commit
b483bf02bb
2 changed files with 17 additions and 1 deletions
  1. +6
    -1
      include/unique_resource.h
  2. +11
    -0
      test/UniqueResourceTest.cpp

+ 6
- 1
include/unique_resource.h View File

@@ -140,8 +140,13 @@ namespace sr
return m_resource;
}

const D& get_deleter() const noexcept
{
return m_deleter;
}


unique_resource& operator=(unique_resource&& other);
unique_resource& operator=(unique_resource&& other); // TODO: Implement
unique_resource& operator=(const unique_resource&) = delete;



+ 11
- 0
test/UniqueResourceTest.cpp View File

@@ -222,4 +222,15 @@ TEST_CASE("get returns resource", "[UniqueResource]")
CHECK(guard.get() == 3);
}

// TODO: Pointer access functions

TEST_CASE("deleter access", "[UniqueResource]")
{
auto guard = sr::make_unique_resource(Handle{3}, deleter);
guard.release();

{
REQUIRE_CALL(m, deleter(8));
guard.get_deleter()(8);
}
}

Loading…
Cancel
Save