5c921a21c4
Summary: Changed on-scope-exit-mechanism from macro (with two auto-generated variables and an all-capturing lambda) to an explicitly created variable that takes an std::function argument. Reviewers: buda, mislav.bradac, teon.banek Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D659
16 lines
295 B
C++
16 lines
295 B
C++
#include "gmock/gmock.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "utils/on_scope_exit.hpp"
|
|
|
|
|
|
TEST(OnScopeExit, BasicUsage) {
|
|
int variable = 1;
|
|
{
|
|
ASSERT_EQ(variable, 1);
|
|
utils::OnScopeExit on_exit([&variable] { variable = 2; });
|
|
EXPECT_EQ(variable, 1);
|
|
}
|
|
EXPECT_EQ(variable, 2);
|
|
}
|