1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
// Copyright 2009 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "../catch.hpp"
#include "rkcommon/utility/OnScopeExit.h"
using rkcommon::utility::OnScopeExit;
SCENARIO("OnScopeExit correctness", "[OnScopeExit]")
{
GIVEN("A value captured by an OnScopeExit lambda")
{
int testValue = 0;
THEN("The value is only affected after OnScopeExit is out of scope")
{
{
OnScopeExit guard([&]() { testValue++; });
REQUIRE(testValue == 0);
}
REQUIRE(testValue == 1);
}
}
}
|