Sfoglia il codice sorgente

Method implemented.

main
offa 7 anni fa
parent
commit
b483bf02bb
2 ha cambiato i file con 17 aggiunte e 1 eliminazioni
  1. +6
    -1
      include/unique_resource.h
  2. +11
    -0
      test/UniqueResourceTest.cpp

+ 6
- 1
include/unique_resource.h Vedi 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 Vedi 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…
Annulla
Salva