Commit bbbe6ed0 by Stefan Philips

[FIX] Catch Exceptions as reference as one should do (and to keep the

        compiler happy)
parent c4eb7f07
......@@ -163,12 +163,12 @@ public:
}
}
TS_ASSERT_THROWS( matrix.at( 0, 4 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( 1, 5 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( 1, 4 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( 1, 100000 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( 3, 1 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( -1, 0 ), WOutOfBounds );
TS_ASSERT_THROWS( matrix.at( 0, 4 ), const WOutOfBounds& );
TS_ASSERT_THROWS( matrix.at( 1, 5 ), const WOutOfBounds& );
TS_ASSERT_THROWS( matrix.at( 1, 4 ), const WOutOfBounds& );
TS_ASSERT_THROWS( matrix.at( 1, 100000 ), const WOutOfBounds& );
TS_ASSERT_THROWS( matrix.at( 3, 1 ), const WOutOfBounds& );
TS_ASSERT_THROWS( matrix.at( -1, 0 ), const WOutOfBounds& );
}
/**
......
......@@ -98,7 +98,7 @@ public:
// add a malformed (name) property
// The name is malformed since the "/" is used as group separator
TS_ASSERT_THROWS( p->addProperty( "4/5", "test4", 1.0 ), WPropertyNameMalformed );
TS_ASSERT_THROWS( p->addProperty( "4/5", "test4", 1.0 ), const WPropertyNameMalformed& );
// this should have created 3 props
TS_ASSERT( p->m_properties.getReadTicket()->get().size() == 3 );
......@@ -109,7 +109,7 @@ public:
TS_ASSERT( p3->getType() == PV_DOUBLE );
// try to add another property with the same name ( regardless of actual type )
TS_ASSERT_THROWS( p->addProperty( "1", "test1", 1.0 ), WPropertyNotUnique );
TS_ASSERT_THROWS( p->addProperty( "1", "test1", 1.0 ), const WPropertyNotUnique& );
}
/**
......@@ -249,7 +249,7 @@ public:
TS_ASSERT( someProp );
// this one does not exist
TS_ASSERT_THROWS( someProp = p->getProperty( "shouldNotBeInTheList" ), WPropertyUnknown );
TS_ASSERT_THROWS( someProp = p->getProperty( "shouldNotBeInTheList" ), const WPropertyUnknown& );
}
/**
......@@ -267,7 +267,7 @@ public:
boost::shared_ptr< WPropertyBase > p4 = psub->addProperty( "4", "test4", std::string( "hello" ) );
// insert a prop with the same name as a sub property
TS_ASSERT_THROWS( p->addProperty( "heySub", "test1", true ), WPropertyNotUnique );
TS_ASSERT_THROWS( p->addProperty( "heySub", "test1", true ), const WPropertyNotUnique& );
/////////////
// exists
......@@ -301,7 +301,7 @@ public:
TS_ASSERT_THROWS_NOTHING( p->getProperty( "heySub/4" ) );
// ensure nothing is found if wrong name is specified
TS_ASSERT_THROWS( p->getProperty( "heySub/1" ), WPropertyUnknown );
TS_ASSERT_THROWS( p->getProperty( "heySub/1" ), const WPropertyUnknown& );
}
/**
......
......@@ -94,7 +94,7 @@ public:
boost::shared_ptr< WPropertyVariable< bool > > p;
TS_ASSERT_THROWS( p = boost::shared_ptr< WPropertyVariable< bool > >( new WPropertyVariable< bool >( "hey/you", "you", false ) ),
WPropertyNameMalformed );
const WPropertyNameMalformed& );
}
/**
......
......@@ -57,11 +57,11 @@ public:
TS_ASSERT_THROWS( parseFromFile(
boost::filesystem::path( W_FIXTURE_PATH + "WStructuredTextParser_test_invalid.txt" )
), WParseError );
), const WParseError& );
TS_ASSERT_THROWS( parseFromFile(
boost::filesystem::path( W_FIXTURE_PATH + "WStructuredTextParser_test_doesnotexist.txt" )
), WFileNotFound );
), const WFileNotFound& );
// NOTE: we do not test parseFromString as both use the same backend functionality
}
......@@ -170,11 +170,11 @@ public:
TS_ASSERT( t.getValues< std::string >( "level0/notexists" ).size() == 0 );
// check operator[] (it uses getValue internally. So we only check for the WNotFound exception)
TS_ASSERT_THROWS( t.operator[]< std::string >( "level0/notexists" ), WNotFound );
TS_ASSERT_THROWS( t.operator[]< std::string >( "level0/notexists" ), const WNotFound& );
// check type conversion
// this is valid for getValue, getValues and [] as they utilize the same function
TS_ASSERT_THROWS( t.operator[]< size_t >( "level0/notuniquekv" ), WTypeMismatch );
TS_ASSERT_THROWS( t.operator[]< size_t >( "level0/notuniquekv" ), const WTypeMismatch& );
TS_ASSERT( t.operator[]< size_t >( "level0/level1/somekv" ) == 123 );
// to ensure case sensitivity:
......
......@@ -202,7 +202,7 @@ public:
void testNoFunction()
{
boost::shared_ptr< FuncType > func;
TS_ASSERT_THROWS( WWorkerThread< FuncType > w( func, 0, 1 ), WException );
TS_ASSERT_THROWS( WWorkerThread< FuncType > w( func, 0, 1 ), const WException& );
}
/**
......@@ -211,7 +211,7 @@ public:
void testThreadId()
{
boost::shared_ptr< FuncType > func( new FuncType( 5 ) );
TS_ASSERT_THROWS( WWorkerThread< FuncType > w( func, 1, 0 ), WException );
TS_ASSERT_THROWS( WWorkerThread< FuncType > w( func, 1, 0 ), const WException& );
}
// restore WASSERT_AS_CASSERT flag
#ifdef WASSERT_FLAG_CHANGED
......
......@@ -64,23 +64,23 @@ public:
TimesVector t;
// test what happens when the input is empty
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when the vector sizes don't match
createData( data, 3, d, t );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t.push_back( 4.0f );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when there is an invalid time value
t.resize( 3 );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t[ 2 ] = -0.0 / 0.0;
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when there are equal time values
t[ 2 ] = t[ 1 ];
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens if the grids don't match
t[ 2 ] = 2.0;
......@@ -100,7 +100,7 @@ public:
boost::shared_ptr< WValueSet< double > > vs( new WValueSet< double >( 0, 1, v, W_DT_DOUBLE ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs, g ) ) );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens if the valuesets data types don't match
d.resize( 3 );
......@@ -111,7 +111,7 @@ public:
boost::shared_ptr< std::vector< float > > v2( new std::vector< float >( 27, 4 ) );
boost::shared_ptr< WValueSet< float > > vs2( new WValueSet< float >( 0, 1, v2, W_DT_FLOAT ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs2, d.front()->getGrid() ) ) );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
}
// test with 2 time slices
......@@ -121,23 +121,23 @@ public:
TimesVector t;
// test what happens when the input is empty
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when the vector sizes don't match
createData( data, 2, d, t );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t.push_back( 4.0f );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when there is an invalid time value
t.resize( 2 );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t[ 1 ] = 0.0f / 0.0f;
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when there are equal time values
t[ 1 ] = t[ 0 ];
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens if the grids don't match
t[ 1 ] = 2.0;
......@@ -157,7 +157,7 @@ public:
boost::shared_ptr< WValueSet< double > > vs( new WValueSet< double >( 0, 1, v, W_DT_DOUBLE ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs, g ) ) );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens if the valuesets data types don't match
d.resize( 2 );
......@@ -168,7 +168,7 @@ public:
boost::shared_ptr< std::vector< float > > v2( new std::vector< float >( 27, 4 ) );
boost::shared_ptr< WValueSet< float > > vs2( new WValueSet< float >( 0, 1, v2, W_DT_FLOAT ) );
d.push_back( boost::shared_ptr< WDataSetScalar const >( new WDataSetScalar( vs2, d.front()->getGrid() ) ) );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
}
// test with 1 time slice
......@@ -178,19 +178,19 @@ public:
TimesVector t;
// test what happens when the input is empty
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when the vector sizes don't match
createData( data, 1, d, t );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t.push_back( 4.0f );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
// test what happens when there is an invalid time value
t.resize( 1 );
TS_ASSERT_THROWS_NOTHING( WDataSetTimeSeries( d, t ) );
t[ 0 ] = -0.0f / 0.0f;
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), WException );
TS_ASSERT_THROWS( WDataSetTimeSeries( d, t ), const WException& );
}
// datasets should be sorted by time
......@@ -325,7 +325,7 @@ public:
TS_ASSERT_EQUALS( 2.0f, f );
f = ts.findNearestTimeSlice( std::numeric_limits< float >::infinity() );
TS_ASSERT_EQUALS( 2.0f, f );
TS_ASSERT_THROWS( ts.findNearestTimeSlice( 0.0 / 0.0 ), WException );
TS_ASSERT_THROWS( ts.findNearestTimeSlice( 0.0 / 0.0 ), const WException& );
}
/**
......@@ -444,15 +444,15 @@ public:
// test invalid times
WVector3d pos( 1.0, 0.5, 1.0 );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -inf, &success ), WException );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -inf, &success ), const WException& );
TS_ASSERT( !success );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -3.0f, &success ), WException );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -3.0f, &success ), const WException& );
TS_ASSERT( !success );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -wlimits::FLT_EPS, &success ), WException );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, -wlimits::FLT_EPS, &success ), const WException& );
TS_ASSERT( !success );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, 2.0f + 2.0f * wlimits::FLT_EPS, &success ), WException );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, 2.0f + 2.0f * wlimits::FLT_EPS, &success ), const WException& );
TS_ASSERT( !success );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, inf, &success ), WException );
TS_ASSERT_THROWS( h = ts.interpolate< double >( pos, inf, &success ), const WException& );
TS_ASSERT( !success );
// test invalid position
......
......@@ -66,9 +66,9 @@ public:
}
{
TS_ASSERT_THROWS_NOTHING( WGridTransformOrtho v( 2.2, 3.3, -1.0 ) );
TS_ASSERT_THROWS( WGridTransformOrtho v( 0.0, 0.0, 1.0 ), WPreconditionNotMet );
TS_ASSERT_THROWS( WGridTransformOrtho v( 0.0, 2.0, 1.0 ), WPreconditionNotMet );
TS_ASSERT_THROWS( WGridTransformOrtho v( 1.0, 1.0, 0.0 ), WPreconditionNotMet );
TS_ASSERT_THROWS( WGridTransformOrtho v( 0.0, 0.0, 1.0 ), const WPreconditionNotMet& );
TS_ASSERT_THROWS( WGridTransformOrtho v( 0.0, 2.0, 1.0 ), const WPreconditionNotMet& );
TS_ASSERT_THROWS( WGridTransformOrtho v( 1.0, 1.0, 0.0 ), const WPreconditionNotMet& );
}
{
WGridTransformOrtho v( 2.2, 3.3, -1.0 );
......@@ -90,7 +90,7 @@ public:
mat( 1, 1 ) = 3.3;
mat( 2, 2 ) = 0.0;
TS_ASSERT_THROWS( WGridTransformOrtho v( mat ), WPreconditionNotMet );
TS_ASSERT_THROWS( WGridTransformOrtho v( mat ), const WPreconditionNotMet& );
}
{
WMatrix< double > mat( 4, 4 );
......@@ -100,7 +100,7 @@ public:
mat( 1, 1 ) = 3.3;
mat( 2, 2 ) = 1.0;
TS_ASSERT_THROWS( WGridTransformOrtho v( mat ), WPreconditionNotMet );
TS_ASSERT_THROWS( WGridTransformOrtho v( mat ), const WPreconditionNotMet& );
}
{
WMatrix< double > mat( 4, 4 );
......
......@@ -72,14 +72,14 @@ public:
boost::shared_ptr< WDataSetSingle > ds = buildTestData();
TS_ASSERT_THROWS( TPVO t( boost::shared_ptr< WDataSetSingle >(),
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), WException );
TS_ASSERT_THROWS( TPVO t( ds, TPVO::FunctionType() ), WException );
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), const WException& );
TS_ASSERT_THROWS( TPVO t( ds, TPVO::FunctionType() ), const WException& );
TS_ASSERT_THROWS( TPVO t( boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( ds->getValueSet(),
boost::shared_ptr< WGrid >() ) ),
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), WException );
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), const WException& );
TS_ASSERT_THROWS( TPVO t( boost::shared_ptr< WDataSetSingle >( new WDataSetSingle( boost::shared_ptr< WValueSetBase >(),
ds->getGrid() ) ),
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), WException );
boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ), const WException& );
TS_ASSERT_THROWS_NOTHING( TPVO t( ds, boost::bind( &WThreadedPerVoxelOperationTest::func, this, _1 ) ) );
......
......@@ -139,7 +139,7 @@ public:
TS_ASSERT_DELTA( wtracking::WTrackingUtility::getDistanceToBoundary( g, v, z ), 0.75, TRACKING_EPS );
v = WVector3d( 1.0, 0.0, 0.0 ) + x * 0.5;
TS_ASSERT_THROWS( wtracking::WTrackingUtility::getDistanceToBoundary( g, v, x ), WException );
TS_ASSERT_THROWS( wtracking::WTrackingUtility::getDistanceToBoundary( g, v, x ), const WException& );
v -= x * 2.0 * TRACKING_EPS;
TS_ASSERT_DELTA( wtracking::WTrackingUtility::getDistanceToBoundary( g, v, x ), 2.0 * TRACKING_EPS, TRACKING_EPS );
......@@ -330,10 +330,10 @@ public:
// now lets do something wrong
wtracking::WThreadedTrackingFunction::IndexType i;
v0[ 0 ] = -1;
TS_ASSERT_THROWS( i = wtracking::WThreadedTrackingFunction::IndexType( g, v0, v1, numSeeds, seedsPerPosition ), WException );
TS_ASSERT_THROWS( i = wtracking::WThreadedTrackingFunction::IndexType( g, v0, v1, numSeeds, seedsPerPosition ), const WException& );
v0[ 0 ] = 0;
v1[ 1 ] = 5;
TS_ASSERT_THROWS( i = wtracking::WThreadedTrackingFunction::IndexType( g, v0, v1, numSeeds, seedsPerPosition ), WException );
TS_ASSERT_THROWS( i = wtracking::WThreadedTrackingFunction::IndexType( g, v0, v1, numSeeds, seedsPerPosition ), const WException& );
}
}
......
......@@ -158,9 +158,9 @@ public:
WValueSet< int8_t > set( 1, 2, v, W_DT_INT8 );
TS_ASSERT_THROWS_NOTHING( set.getSubArray( 0, 2 ) );
TS_ASSERT_THROWS_NOTHING( set.getSubArray( 3, 1 ) );
TS_ASSERT_THROWS( set.getSubArray( 4, 1 ), WException );
TS_ASSERT_THROWS( set.getSubArray( 3, 2 ), WException );
TS_ASSERT_THROWS( set.getSubArray( 2, 0 ), WException );
TS_ASSERT_THROWS( set.getSubArray( 4, 1 ), const WException& );
TS_ASSERT_THROWS( set.getSubArray( 3, 2 ), const WException& );
TS_ASSERT_THROWS( set.getSubArray( 2, 0 ), const WException& );
}
/**
......
......@@ -461,7 +461,7 @@ public:
initModules();
// try initializing twice
TS_ASSERT_THROWS( m1->initialize(), WModuleConnectorInitFailed );
TS_ASSERT_THROWS( m1->initialize(), const WModuleConnectorInitFailed& );
TS_ASSERT( m1->isInitialized()() );
}
......@@ -476,8 +476,8 @@ public:
initModules();
// connect input with input and output with output should fail
TS_ASSERT_THROWS( m1->m_input->connect( m2->m_input ), WModuleConnectorsIncompatible );
TS_ASSERT_THROWS( m1->m_output->connect( m2->m_output ), WModuleConnectorsIncompatible );
TS_ASSERT_THROWS( m1->m_input->connect( m2->m_input ), const WModuleConnectorsIncompatible& );
TS_ASSERT_THROWS( m1->m_output->connect( m2->m_output ), const WModuleConnectorsIncompatible& );
// there should be nothing connected.
TS_ASSERT( m1->m_output->m_connected.size() == 0 );
......@@ -507,7 +507,7 @@ public:
TS_ASSERT( m2->m_outputDerived->m_connected.size() == 1 );
// connect an input of derived type with output of base type
TS_ASSERT_THROWS( m1->m_output->connect( m2->m_inputDerived ), WModuleConnectorsIncompatible );
TS_ASSERT_THROWS( m1->m_output->connect( m2->m_inputDerived ), const WModuleConnectorsIncompatible& );
TS_ASSERT( m1->m_output->m_connected.size() == 0 );
TS_ASSERT( m1->m_inputDerived->m_connected.size() == 0 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment