File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+ import beman.scope;
4+ // #include <stdexcept>
5+ // #include <string>
6+ #include < cassert>
7+
8+ // #define CATCH_CONFIG_MAIN
9+ // #include <catch2/catch_all.hpp>
10+
11+ // clang-format off
12+ // struct noisy_resource {
13+ // noisy_resource() { std::print( "construct noisy\n" ); }
14+ // ~noisy_resource() { std::print( "destroy noisy\n" ); }
15+ // };
16+
17+ // TEST_CASE("module-test", "[scope_module_test]") {
18+ int main ()
19+ {
20+ bool exit_ran, success_ran, fail_ran = false ;
21+ {
22+ beman::scope::scope_exit _ ([&exit_ran] { exit_ran = true ; });
23+ beman::scope::scope_success _ ([&success_ran] { success_ran = true ; });
24+ beman::scope::scope_fail _ ([&fail_ran] { fail_ran = true ; });
25+ // auto resource_ptr = beman::scope::unique_resource(new noisy_resource(),
26+ // // Cleanup function
27+ // [](noisy_resource* ptr) { delete ptr; });
28+ } // Normal scope exit
29+
30+ assert (exit_ran == true );
31+ assert (success_ran == true );
32+ assert (fail_ran == false );
33+
34+ }
You can’t perform that action at this time.
0 commit comments