Types - T_Optional access

Changed so it's relatively similar to the interface of pointers.
This commit is contained in:
Emmanuel BENOîT 2017-11-07 17:40:02 +01:00
parent 82fc8406b3
commit 46fa84d967
5 changed files with 48 additions and 21 deletions

View file

@ -92,15 +92,15 @@ struct T_Counter_
#define M_EMPTY_( O ) \
do { \
CPPUNIT_ASSERT( ! ( O ).present( ) ); \
CPPUNIT_ASSERT( ! ( O ) ); \
CPPUNIT_ASSERT( ( O ).target( ) == nullptr ); \
} while ( 0 )
#define M_VALUE_( O , V ) \
do { \
CPPUNIT_ASSERT( ( O ).present( ) ); \
CPPUNIT_ASSERT( ( O ) ); \
CPPUNIT_ASSERT( ( O ).target( ) != nullptr ); \
CPPUNIT_ASSERT_EQUAL( int( V ) , ( O ).target( )->value ); \
CPPUNIT_ASSERT_EQUAL( int( V ) , ( O )->value ); \
} while ( 0 )
} // namespace
@ -271,7 +271,7 @@ void OptionalTest::testClear( )
void OptionalTest::testCast( )
{
const T_Optional< T_Counter_ > s{ Construct< T_Counter_ >( ) , 12 };
T_Counter_ cnt( s );
T_Counter_ cnt( *s );
CPPUNIT_ASSERT_EQUAL( 12 , cnt.value );
}
@ -279,7 +279,7 @@ void OptionalTest::testCastException( )
{
const T_Optional< T_Counter_ > s;
try {
T_Counter_ cnt( s );
T_Counter_ cnt( *s );
CPPUNIT_FAIL( "std::bad_cast not thrown" );
} catch ( std::bad_cast const& ) {
// OK