From: jmo Date: Wed, 1 Dec 2010 15:51:47 +0000 (+0000) Subject: unit test fix for jaunty and before X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=7a9d26ea01ae0fb7f3d2a046ae19f8ceb9c4a9b6;p=senf.git unit test fix for jaunty and before git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1752 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/StatisticAccumulator.ct b/senf/Utils/StatisticAccumulator.ct index c0b83ae..adefd6c 100644 --- a/senf/Utils/StatisticAccumulator.ct +++ b/senf/Utils/StatisticAccumulator.ct @@ -32,13 +32,12 @@ // senf::StatisticAccumulator template -prefix_ senf::StatisticAccumulator::StatisticAccumulator( T defaultvalue) - : defaultvalue_(defaultvalue), - sum_squared_(defaultvalue*defaultvalue), - sum_(defaultvalue), - min_(defaultvalue), - max_(defaultvalue), - last_avg_(float(defaultvalue)), +prefix_ senf::StatisticAccumulator::StatisticAccumulator( ) + : sum_squared_(0), + sum_(0), + min_(0), + max_(0), + last_avg_(0), count_(0) { } @@ -84,8 +83,8 @@ prefix_ void senf::StatisticAccumulator::clear() { last_avg_ = avg(); count_ = 0; - sum_squared_ = defaultvalue_*defaultvalue_; - sum_ = min_ = max_ = defaultvalue_; + sum_squared_ = 0; + sum_ = min_ = max_ = 0; } diff --git a/senf/Utils/StatisticAccumulator.hh b/senf/Utils/StatisticAccumulator.hh index 6c08c41..388ef99 100644 --- a/senf/Utils/StatisticAccumulator.hh +++ b/senf/Utils/StatisticAccumulator.hh @@ -50,13 +50,12 @@ namespace senf { class StatisticAccumulator { public: - StatisticAccumulator( T defaultvalue = 0); + StatisticAccumulator(); // virtual ~StatisticAccumulator(); void clear(); ///< Reset accumulated values. - /**< This member reset all avg/min/max values to the given \a - defaultvalue and the count to zero. */ + /**< This member reset all values. */ void accumulate(T value); ///< Gather value to be accumulated. /**< This method accumulate a value. @@ -83,7 +82,6 @@ namespace senf { /**< This method returns count of accumulated values of the current accumulation.*/ private: - T defaultvalue_; T sum_squared_; T sum_; T min_; diff --git a/senf/Utils/StatisticAccumulator.test.cc b/senf/Utils/StatisticAccumulator.test.cc index 17059e8..9bea12b 100644 --- a/senf/Utils/StatisticAccumulator.test.cc +++ b/senf/Utils/StatisticAccumulator.test.cc @@ -29,7 +29,8 @@ #include "Statistics.hh" #include "auto_unit_test.hh" #include -#include +#include +//#include #define prefix_ ///////////////////////////////ct.p//////////////////////////////////////// @@ -56,9 +57,10 @@ SENF_AUTO_UNIT_TEST(StatisticAccumulator) BOOST_CHECK_EQUAL( sa.max(), 0); BOOST_CHECK_EQUAL( sa.min(), 0); - BOOST_CHECK( (boost::math::isnan)( sa.avg())); +// BOOST_CHECK( (boost::math::isnan)( sa.avg())); + BOOST_CHECK( ::isnan( sa.avg()) != 0); BOOST_CHECK_EQUAL( sa.last_avg(), 5.0); - BOOST_CHECK( (boost::math::isnan)( sa.stddev())); + BOOST_CHECK( ::isnan( sa.stddev())); BOOST_CHECK_EQUAL( sa.count(), 0);