//---------------------------------------------------------------------------// // Test the insist macro for DBC. TEUCHOS_UNIT_TEST( Assertion, _test ) { try { std::string in_message( "test message content" ); MCLS_INSIST( 0, in_message ); throw std::runtime_error( "this shouldn't be thrown" ); } catch( const MCLS::Assertion& assertion ) { TEST_ASSERT( 1 ); std::string message( assertion.what() ); std::string true_message( "test message content" ); std::string::size_type idx = message.find( true_message ); if ( idx == std::string::npos ) { TEST_ASSERT( 0 ); } } catch( ... ) { TEST_ASSERT( 0 ); } }
//---------------------------------------------------------------------------// // Test the invariant check for DBC. TEUCHOS_UNIT_TEST( DataTransferKitException, invariant_test ) { try { DTK_CHECK( 0 ); throw std::runtime_error( "this shouldn't be thrown" ); } catch( const DataTransferKit::DataTransferKitException& assertion ) { #if HAVE_DTK_DBC std::string message( assertion.what() ); std::string true_message( "DataTransferKit DataTransferKitException: 0, failed in" ); std::string::size_type idx = message.find( true_message ); if ( idx == std::string::npos ) { TEST_ASSERT( 0 ); } #else TEST_ASSERT( 0 ); #endif } catch( ... ) { #if HAVE_DTK_DBC TEST_ASSERT( 0 ); #endif } }
//---------------------------------------------------------------------------// // Test the postcondition check for DBC. TEUCHOS_UNIT_TEST( Assertion, postcondition_test ) { try { MCLS_ENSURE( 0 ); throw std::runtime_error( "this shouldn't be thrown" ); } catch( const MCLS::Assertion& assertion ) { #if HAVE_MCLS_DBC std::string message( assertion.what() ); std::string true_message( "MCLS Assertion: 0, failed in" ); std::string::size_type idx = message.find( true_message ); if ( idx == std::string::npos ) { TEST_ASSERT( 0 ); } #else TEST_ASSERT( 0 ); #endif } catch( ... ) { #if HAVE_MCLS_DBC TEST_ASSERT( 0 ); #endif } }
//---------------------------------------------------------------------------// // Test the assertion check for DBC. TEUCHOS_UNIT_TEST( DataTransferKitException, assertion_test ) { try { DTK_INSIST( 0 ); throw std::runtime_error( "this shouldn't be thrown" ); } catch( const DataTransferKit::DataTransferKitException& assertion ) { std::string message( assertion.what() ); std::string true_message( "DataTransferKit DataTransferKitException: 0, failed in" ); std::string::size_type idx = message.find( true_message ); if ( idx == std::string::npos ) { TEST_ASSERT( 0 ); } } catch( ... ) { TEST_ASSERT( 0 ); } }