forked from Alepha/Alepha
Assertion facility.
This commit is contained in:
@ -32,6 +32,7 @@ add_subdirectory( word_wrap.test )
|
||||
add_subdirectory( string_algorithms.test )
|
||||
add_subdirectory( tuplize_args.test )
|
||||
add_subdirectory( Thread.test )
|
||||
add_subdirectory( assertion.test )
|
||||
|
||||
# Sample applications
|
||||
add_executable( example example.cc )
|
||||
|
30
assertion.h
Normal file
30
assertion.h
Normal file
@ -0,0 +1,30 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Alepha/Alepha.h>
|
||||
|
||||
#include <Alepha/Exception.h>
|
||||
|
||||
namespace Alepha::Hydrogen ::detail:: assertion_m
|
||||
{
|
||||
inline namespace exports
|
||||
{
|
||||
class ProgrammerExpectationViolation : public virtual Violation {};
|
||||
|
||||
inline void
|
||||
assertion( const bool b )
|
||||
{
|
||||
if( not b )
|
||||
{
|
||||
throw build_exception< ProgrammerExpectationViolation >(
|
||||
"Expectation violated." );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Alepha::Hydrogen::inline exports::inline assertion_m
|
||||
{
|
||||
using namespace detail::assertion_m::exports;
|
||||
}
|
4
assertion.test/0.cc
Normal file
4
assertion.test/0.cc
Normal file
@ -0,0 +1,4 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include "../assertion.h"
|
||||
|
1
assertion.test/CMakeLists.txt
Normal file
1
assertion.test/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
unit_test( 0 )
|
Reference in New Issue
Block a user