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; }
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()); } }