瀏覽代碼

Refactoring.

main
offa 7 年之前
父節點
當前提交
b9b7126260
共有 2 個文件被更改,包括 14 次插入12 次删除
  1. +8
    -3
      test/ScopeGuardTest.cpp
  2. +6
    -9
      test/UniqueResourceTest.cpp

+ 8
- 3
test/ScopeGuardTest.cpp 查看文件

@@ -20,13 +20,18 @@

#include "scope_guard.h"
#include <catch.hpp>
#include "Mocks.h"
#include <trompeloeil.hpp>

using namespace trompeloeil;

namespace
{
mock::CallMock m;
struct CallMock
{
MAKE_MOCK0(deleter, void());
};

CallMock m;

void deleter()
{
@@ -51,7 +56,7 @@ TEST_CASE("deleter is not called if released", "[ScopeGuard]")

TEST_CASE("deleter lambda called on destruction", "[ScopeGuard]")
{
mock::CallMock cm;
CallMock cm;
REQUIRE_CALL(cm, deleter());
auto guard = sr::scope_guard([&cm] { cm.deleter(); });
static_cast<void>(guard);

+ 6
- 9
test/UniqueResourceTest.cpp 查看文件

@@ -25,21 +25,18 @@

using namespace trompeloeil;

using Handle = int;
using PtrHandle = std::add_pointer_t<Handle>;

namespace mock
namespace
{
using Handle = int;
using PtrHandle = std::add_pointer_t<Handle>;


struct CallMock
{
MAKE_MOCK1(deleter, void(Handle));
};
}


namespace
{
mock::CallMock m;
CallMock m;

void deleter(Handle h)
{

Loading…
取消
儲存