diff --git a/test/misc/cleanup.cpp b/test/misc/cleanup.cpp new file mode 100644 index 00000000..8144354d --- /dev/null +++ b/test/misc/cleanup.cpp @@ -0,0 +1,30 @@ +#include +#include + +#include +#include +#include + +#include + +using namespace openvpn; + +int main(int /*argc*/, char* /*argv*/[]) +{ + try { + std::unique_ptr str(new std::string("Hello world!")); + auto c = Cleanup([str=std::move(str)]() { + OPENVPN_LOG("HIT IT: " << *str); + }); + static_assert(std::is_nothrow_move_constructible::value, + "Cleanup should be noexcept MoveConstructible"); + + OPENVPN_LOG("Starting..."); + } + catch (const std::exception& e) + { + std::cerr << "Exception: " << e.what() << std::endl; + return 1; + } + return 0; +}