forked from Alepha/Alepha
34 lines
856 B
C++
34 lines
856 B
C++
static_assert( __cplusplus > 2020'99 );
|
|
|
|
#include <Alepha/AutoRAII.h>
|
|
|
|
#include <Alepha/Testing/test.h>
|
|
#include <Alepha/Utility/evaluation_helpers.h>
|
|
|
|
static auto tests= Alepha::Utility::enroll <=[]
|
|
{
|
|
using namespace Alepha::Hydrogen::exports::AutoRAII_m;
|
|
using namespace Alepha::Testing::exports::literals;
|
|
|
|
using Alepha::Testing::exports::TestState;
|
|
|
|
"basic.syntax"_test <=[]( TestState test )
|
|
{
|
|
AutoRAII managed{ []{ return 42; }, []( auto ){} };
|
|
test.expect( managed == 42 );
|
|
};
|
|
|
|
"basic.functionality"_test <=[]( TestState test )
|
|
{
|
|
bool initialized= false;
|
|
bool destroyed= false;
|
|
{
|
|
AutoRAII managed{ [&]{ initialized= true; return 0; }, [&]( auto ) { initialized= false; destroyed= true; } };
|
|
test.expect( initialized );
|
|
test.expect( not destroyed );
|
|
}
|
|
test.expect( not initialized );
|
|
test.expect( destroyed );
|
|
};
|
|
};
|