瀏覽代碼

Method implemented.

main
offa 7 年之前
父節點
當前提交
b483bf02bb
共有 2 個檔案被更改,包括 17 行新增1 行删除
  1. +6
    -1
      include/unique_resource.h
  2. +11
    -0
      test/UniqueResourceTest.cpp

+ 6
- 1
include/unique_resource.h 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存