diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 10:51:19 +0000 |
commit | eb11fae6d08f479c0799db45860a98af528fa6e7 (patch) | |
tree | 44d492a50c8c1a7eb8e2d17ea3360ec4d066f042 /unittests/ADT/ScopeExitTest.cpp | |
parent | b8a2042aa938069e862750553db0e4d82d25822c (diff) |
Notes
Diffstat (limited to 'unittests/ADT/ScopeExitTest.cpp')
-rw-r--r-- | unittests/ADT/ScopeExitTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/ADT/ScopeExitTest.cpp b/unittests/ADT/ScopeExitTest.cpp index 301942c30bbc..ab11dff8ce48 100644 --- a/unittests/ADT/ScopeExitTest.cpp +++ b/unittests/ADT/ScopeExitTest.cpp @@ -29,4 +29,21 @@ TEST(ScopeExitTest, Basic) { EXPECT_TRUE(Called); } +TEST(ScopeExitTest, Release) { + int Count = 0; + auto Increment = [&] { ++Count; }; + { + auto G = make_scope_exit(Increment); + auto H = std::move(G); + auto I = std::move(G); + EXPECT_EQ(0, Count); + } + EXPECT_EQ(1, Count); + { + auto G = make_scope_exit(Increment); + G.release(); + } + EXPECT_EQ(1, Count); +} + } // end anonymous namespace |