1
0
forked from Alepha/Alepha

Mailbox has been modernized.

This commit is contained in:
2023-11-16 07:32:56 -05:00
parent 4dac28a2c3
commit 4426fc2857
5 changed files with 249 additions and 163 deletions

55
Atomic/Mailbox.test/0.cc Normal file
View 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(); }
};
};

View File

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