1
0
forked from Alepha/Alepha

Assertion facility.

This commit is contained in:
2023-11-10 23:18:07 -05:00
parent 0d66b5a135
commit 0728478f24
4 changed files with 36 additions and 0 deletions

View File

@ -32,6 +32,7 @@ add_subdirectory( word_wrap.test )
add_subdirectory( string_algorithms.test ) add_subdirectory( string_algorithms.test )
add_subdirectory( tuplize_args.test ) add_subdirectory( tuplize_args.test )
add_subdirectory( Thread.test ) add_subdirectory( Thread.test )
add_subdirectory( assertion.test )
# Sample applications # Sample applications
add_executable( example example.cc ) add_executable( example example.cc )

30
assertion.h Normal file
View 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
View File

@ -0,0 +1,4 @@
static_assert( __cplusplus > 2020'99 );
#include "../assertion.h"

View File

@ -0,0 +1 @@
unit_test( 0 )