1 //===- llvm/unittest/ADT/ScopeExit.cpp - Scope exit unit tests --*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/ScopeExit.h"
10 #include "gtest/gtest.h"
16 TEST(ScopeExitTest
, Basic
) {
19 Callable(bool &Called
) : Called(Called
) {}
20 Callable(Callable
&&RHS
) : Called(RHS
.Called
) {}
21 void operator()() { Called
= true; }
25 auto g
= make_scope_exit(Callable(Called
));
31 TEST(ScopeExitTest
, Release
) {
33 auto Increment
= [&] { ++Count
; };
35 auto G
= make_scope_exit(Increment
);
36 auto H
= std::move(G
);
37 auto I
= std::move(G
);
42 auto G
= make_scope_exit(Increment
);
48 } // end anonymous namespace