memgraph/tests/unit/utils_on_scope_exit.cpp
florijan 5c921a21c4 utils::auto_scope refactor
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
2017-08-11 09:43:10 +02:00

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);
}