Skip to content

Commit 8000dfd

Browse files
committed
initial draft of module test even though cant cmake compile yet
1 parent a6ffc6e commit 8000dfd

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/module.test.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
}

0 commit comments

Comments
 (0)