mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
[test/misc] Added tests for classes Stop and Cleanup.
This commit is contained in:
parent
4e85ec0722
commit
6c2babf73b
30
test/misc/cleanup.cpp
Normal file
30
test/misc/cleanup.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
||||
#include <openvpn/log/logsimple.hpp>
|
||||
#include <openvpn/common/size.hpp>
|
||||
#include <openvpn/common/exception.hpp>
|
||||
|
||||
#include <openvpn/common/cleanup.hpp>
|
||||
|
||||
using namespace openvpn;
|
||||
|
||||
int main(int /*argc*/, char* /*argv*/[])
|
||||
{
|
||||
try {
|
||||
std::unique_ptr<std::string> 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<decltype(c)>::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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user