コード例 #1
0
void TestNormalDistribution::testClone()
{
  NormalDistribution distSigmaWithNumDeviations( *mean, *stdDev, numDevs );
  NormalDistribution distSigmaWithoutNumDeviations( *mean, *stdDev );
  NormalDistribution distBoundsWithoutNumDeviations( lb, ub );
  NormalDistribution distBoundsWithNumDeviations( lb, ub, numDevs );
   
   // call clone and test results
   NormalDistribution* rtn = (NormalDistribution*)distSigmaWithNumDeviations.clone();

   _test( rtn->lowerBound() == distSigmaWithNumDeviations.lowerBound() );
   _test( rtn->upperBound() == distSigmaWithNumDeviations.upperBound() );
   _test( rtn->mean() == distSigmaWithNumDeviations.mean() );
   _test( rtn->stdDev() == distSigmaWithNumDeviations.stdDev() );
   _test( rtn->typeName() == distSigmaWithNumDeviations.typeName() );

   // clean up memory
   delete rtn;

   // call clone and test results
   rtn = (NormalDistribution*)distSigmaWithoutNumDeviations.clone();

   _test( rtn->lowerBound() == distSigmaWithoutNumDeviations.lowerBound() );
   _test( rtn->upperBound() == distSigmaWithoutNumDeviations.upperBound() );
   _test( rtn->mean() == distSigmaWithoutNumDeviations.mean() );
   _test( rtn->stdDev() == distSigmaWithoutNumDeviations.stdDev() );
   _test( rtn->typeName() == distSigmaWithoutNumDeviations.typeName() );

   // clean up memory
   delete rtn;

   // call clone and test results
   rtn = (NormalDistribution*)distBoundsWithoutNumDeviations.clone();

   _test( rtn->lowerBound() == distBoundsWithoutNumDeviations.lowerBound() );
   _test( rtn->upperBound() == distBoundsWithoutNumDeviations.upperBound() );
   _test( rtn->mean() == distBoundsWithoutNumDeviations.mean() );
   _test( rtn->stdDev() == distBoundsWithoutNumDeviations.stdDev() );
   _test( rtn->typeName() == distBoundsWithoutNumDeviations.typeName() );

   // clean up memory
   delete rtn;

   // call clone and test results
   rtn = (NormalDistribution*)distBoundsWithNumDeviations.clone();

   _test( rtn->lowerBound() ==distBoundsWithNumDeviations.lowerBound() );
   _test( rtn->upperBound() ==distBoundsWithNumDeviations.upperBound() );
   _test( rtn->mean() ==distBoundsWithNumDeviations.mean() );
   _test( rtn->stdDev() ==distBoundsWithNumDeviations.stdDev() );
   _test( rtn->typeName() ==distBoundsWithNumDeviations.typeName() );

   // clean up memory
   delete rtn;
}
コード例 #2
0
TEST_F(AnalysisFixture, NormalDistribution) {

  //Check default constructor
  NormalDistribution defaultDistribution;
  EXPECT_EQ(defaultDistribution.mean(),0.0);
  EXPECT_EQ(defaultDistribution.standardDeviation(),1.0);
  EXPECT_EQ(defaultDistribution.lowerBound(),boost::none);

  //Check normal constructor
  NormalDistribution distribution(2.0,3.0);
  distribution.setLowerBound(0.0);
  distribution.setUpperBound(4.0);
  EXPECT_EQ(distribution.mean(),2.0);
  EXPECT_EQ(distribution.standardDeviation(),3.0);
  EXPECT_EQ(distribution.lowerBound(),0.0);
  EXPECT_EQ(distribution.upperBound(),4.0);
  
}
コード例 #3
0
TEST_F(AnalysisFixture,UncertaintyDescription_ConstructionCopyingAndCasting) {
  NormalDistribution stdNormal;
  {
    UncertaintyDescription baseCopy = stdNormal; // copies impl
  } // calls destructor
  EXPECT_DOUBLE_EQ(0.0,stdNormal.mean());
  EXPECT_DOUBLE_EQ(1.0,stdNormal.standardDeviation());
  EXPECT_FALSE(stdNormal.lowerBound());
  EXPECT_FALSE(stdNormal.upperBound());

  {
    UncertaintyDescription baseCopy(stdNormal);
    NormalDistribution stdNormalCopy = baseCopy.cast<NormalDistribution>();
    EXPECT_EQ(UncertaintyDescriptionType(UncertaintyDescriptionType::normal_uncertain),baseCopy.type());
  }

  {
    GenericUncertaintyDescription genericCopy = stdNormal.cast<GenericUncertaintyDescription>();
    EXPECT_EQ(2u,genericCopy.attributes().size());
  }

}