diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-01-25 16:55:48 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-01-25 16:55:48 +0000 |
commit | 7e6d025540f03b4df8700e363229c6dd88b4886d (patch) | |
tree | 254c4800ec96cd5146fd2cefcb4a7f77d2aed8f2 /llvm/unittests/ADT/ScopeExitTest.cpp | |
parent | c8cfa14b6dc43922516e4a0e40a5eb6a8672d0d9 (diff) | |
download | bcm5719-llvm-7e6d025540f03b4df8700e363229c6dd88b4886d.tar.gz bcm5719-llvm-7e6d025540f03b4df8700e363229c6dd88b4886d.zip |
Give scope_exit helper correct move semantics
llvm-svn: 323442
Diffstat (limited to 'llvm/unittests/ADT/ScopeExitTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/ScopeExitTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/ScopeExitTest.cpp b/llvm/unittests/ADT/ScopeExitTest.cpp index 301942c30bb..ab11dff8ce4 100644 --- a/llvm/unittests/ADT/ScopeExitTest.cpp +++ b/llvm/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 |