forked from Alepha/Alepha
58 lines
1.7 KiB
C++
58 lines
1.7 KiB
C++
static_assert( __cplusplus > 2020'99 );
|
|
|
|
#include "../Mailbox.h"
|
|
|
|
#include <Alepha/Testing/test.h>
|
|
#include <Alepha/Testing/TableTest.h>
|
|
|
|
#include <cassert>
|
|
|
|
static auto init= Alepha::Utility::enroll <=[]
|
|
{
|
|
using namespace Alepha::Testing::exports;
|
|
using namespace Alepha::Testing::literals;
|
|
|
|
"Smoke Test"_test <=[]
|
|
{
|
|
Alepha::Atomic::Mailbox< int > m( 1024 );
|
|
|
|
m.push( 42 );
|
|
m.push( 42 );
|
|
m.finish();
|
|
|
|
assert( m.pop() == 42 );
|
|
assert( m.pop() == 42 );
|
|
|
|
try
|
|
{
|
|
m.pop();
|
|
std::cerr << "We passed the last pop!" << std::endl;
|
|
assert( false );
|
|
}
|
|
catch( const Alepha::Exception &cond )
|
|
{
|
|
std::cerr << "We caught an exception." << std::endl;
|
|
const Alepha::Exception *const cond_p= &cond;
|
|
|
|
assert( dynamic_cast< const Alepha::Atomic::MailboxFinishedException * >( cond_p ) );
|
|
assert( dynamic_cast< const Alepha::FinishedException * >( cond_p ) );
|
|
assert( dynamic_cast< const Alepha::Exception * >( cond_p ) );
|
|
|
|
assert( dynamic_cast< const Alepha::Atomic::MailboxFinishedCondition * >( cond_p ) );
|
|
assert( dynamic_cast< const Alepha::FinishedCondition * >( cond_p ) );
|
|
assert( dynamic_cast< const Alepha::Condition * >( cond_p ) );
|
|
|
|
|
|
|
|
assert( not dynamic_cast< const Alepha::Atomic::AnyTaggedMailboxFinishedException * >( cond_p ) );
|
|
assert( not dynamic_cast< const Alepha::AnyTaggedFinishedException * >( cond_p ) );
|
|
assert( not dynamic_cast< const Alepha::AnyTaggedException * >( cond_p ) );
|
|
|
|
assert( not dynamic_cast< const Alepha::Atomic::AnyTaggedMailboxFinishedCondition * >( cond_p ) );
|
|
assert( not dynamic_cast< const Alepha::AnyTaggedFinishedCondition * >( cond_p ) );
|
|
assert( not dynamic_cast< const Alepha::AnyTaggedCondition * >( cond_p ) );
|
|
}
|
|
catch( ... ) { abort(); }
|
|
};
|
|
};
|