forked from Alepha/Alepha
Mailbox has been modernized.
This commit is contained in:
55
Atomic/Mailbox.test/0.cc
Normal file
55
Atomic/Mailbox.test/0.cc
Normal file
@ -0,0 +1,55 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include "../Mailbox.h"
|
||||
|
||||
#include <Alepha/Testing/test.h>
|
||||
#include <Alepha/Testing/TableTest.h>
|
||||
|
||||
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(); }
|
||||
};
|
||||
};
|
||||
1
Atomic/Mailbox.test/CMakeLists.txt
Normal file
1
Atomic/Mailbox.test/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
unit_test( 0 )
|
||||
Reference in New Issue
Block a user