MCPcopy Create free account
hub / github.com/ImageEngine/cortex / testSignedScaled

Method testSignedScaled

test/IECore/DataConversionTest.h:62–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60{
61 template<typename F, typename T>
62 void testSignedScaled()
63 {
64 typedef ScaledDataConversion< F, T > Func;
65
66 Func f;
67 CompoundDataConversion< Func, typename Func::InverseType > f_fi( f, f.inverse() );
68
69 unsigned seed = 42;
70 boost::mt19937 generator( static_cast<boost::mt19937::result_type>( seed ) );
71
72 /// Create a random number generator within this range
73 boost::uniform_real<> uni_dist( std::numeric_limits<F>::min(), std::numeric_limits<F>::max() );
74 boost::variate_generator<boost::mt19937&, boost::uniform_real<> > uni(generator, uni_dist);
75
76 const int numTests = 100;
77 for ( int t = 0; t < numTests; t++)
78 {
79 F i = static_cast<F>( uni() );
80
81 /// Verify that f(f'(i)) ~ i
82 BOOST_CHECK_CLOSE( double( f_fi(i) ), double( i ), 1.e-4 );
83 }
84 }
85};
86
87struct DataConversionTestSuite : public boost::unit_test::test_suite

Callers

nothing calls this directly

Calls 1

inverseMethod · 0.80

Tested by

no test coverage detected