void testDecomposeRQ3x3() { try { srand(1); // This test produces an incorrect result when the validation check in givensDecomposeRQ3x3 isn't used. decomposeTest( ( Eigen::Vector3d() << degreesToRadians( -90. ), degreesToRadians( 24.5916 ), degreesToRadians( -90. ) ).finished(), ( Eigen::Matrix3d() << 1.94444, 0, 0, 0, 2.1875, 0, 0.0141111, 0.127, 1. ).finished() ); for( unsigned int i = 0; i < 1000; ++i ) { decomposeTest( ( Eigen::Vector3d() << randomNumber( -M_PI*.5, M_PI*.5 ), randomNumber( -M_PI*.5, M_PI*.5 ), randomNumber( -M_PI*.5, M_PI*.5 ) ).finished(), ( Eigen::Matrix3d() << randomNumber( 0.1, 3. ), 0, 0, 0, randomNumber( 0.1, 3. ), 0, randomNumber( 0.1, 3. ), randomNumber( 0.1, 3. ), 1. ).finished() ); } } catch ( std::exception &e ) { BOOST_WARN( !e.what() ); BOOST_CHECK( !"Exception thrown during DecomposeRQ3x3Test." ); } }
void testMemberRetrieval() { CompoundDataPtr c = new CompoundData(); c->writable()["floatElement"] = new FloatData( 42.0f ); c->writable()["stringElement"] = new StringData( "cake" ); try { FloatData *f = c->member<FloatData>( "floatElement", false ); BOOST_CHECK( f ); BOOST_CHECK( f->staticTypeId() == FloatData::staticTypeId() ); IntData *i = c->member<IntData>( "floatElement", false ); BOOST_CHECK( !i ); StringData *s = c->member<StringData>( "iAmMissing", false ); BOOST_CHECK( !s ); } catch ( std::exception &e ) { BOOST_WARN( !e.what() ); BOOST_CHECK( !"Exception thrown during member retrieval with exceptions disabled." ); } try { FloatData *f = c->member<FloatData>( "floatElement", true ); BOOST_REQUIRE( f ); BOOST_CHECK( f->staticTypeId() == FloatData::staticTypeId() ); StringData *s = c->member<StringData>( "stringElement", true ); BOOST_REQUIRE( s ); BOOST_CHECK( s->staticTypeId() == StringData::staticTypeId() ); } catch ( std::exception &e ) { BOOST_WARN( !e.what() ); BOOST_CHECK( !"Exception thrown during member retrieval." ); } try { IntData *i = c->member<IntData>( "floatElement", true ); BOOST_CHECK( !"Exception not thrown during invalid member retrieval." ); BOOST_CHECK( !i ); } catch ( IECore::Exception &e ) { } catch( ... ) { BOOST_CHECK( !"Incorrect exception type thrown during invalid member retrieval." ); } try { StringData *s = c->member<StringData>( "iAmMissing", true, false ); BOOST_CHECK( !"Exception not thrown during missing member retrieval." ); BOOST_CHECK( !s ); } catch ( IECore::Exception &e ) { } catch( ... ) { BOOST_CHECK( !"Incorrect exception type thrown during invalid member retrieval." ); } try { StringData *s = c->member<StringData>( "iAmMissing", true, true ); BOOST_REQUIRE( s ); BOOST_CHECK( s->staticTypeId() == StringData::staticTypeId() ); FloatData *f = c->member<CompoundData>( "newParent", true, true )->member<FloatData>( "newChild", true, true ); BOOST_REQUIRE( f ); BOOST_CHECK( f->staticTypeId() == FloatData::staticTypeId() ); } catch ( std::exception &e ) { BOOST_CHECK( !"Exception thrown during creation of member." ); } }