unit test fix for jaunty and before
jmo [Wed, 1 Dec 2010 15:51:47 +0000 (15:51 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1752 270642c3-0616-0410-b53a-bc976706d245

senf/Utils/StatisticAccumulator.ct
senf/Utils/StatisticAccumulator.hh
senf/Utils/StatisticAccumulator.test.cc

index c0b83ae..adefd6c 100644 (file)
 // senf::StatisticAccumulator<T>
 
 template <class T>
-prefix_ senf::StatisticAccumulator<T>::StatisticAccumulator( T defaultvalue)
-    : defaultvalue_(defaultvalue),
-      sum_squared_(defaultvalue*defaultvalue),
-      sum_(defaultvalue),
-      min_(defaultvalue),
-      max_(defaultvalue),
-      last_avg_(float(defaultvalue)),
+prefix_ senf::StatisticAccumulator<T>::StatisticAccumulator( )
+    : sum_squared_(0),
+      sum_(0),
+      min_(0),
+      max_(0),
+      last_avg_(0),
       count_(0)
 {
 }
@@ -84,8 +83,8 @@ prefix_ void senf::StatisticAccumulator<T>::clear()
 {
     last_avg_ = avg();
     count_ = 0;
-    sum_squared_ = defaultvalue_*defaultvalue_;
-    sum_ = min_ = max_ = defaultvalue_;
+    sum_squared_ = 0;
+    sum_ = min_ = max_ = 0;
 }
 
 
index 6c08c41..388ef99 100644 (file)
@@ -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_;
index 17059e8..9bea12b 100644 (file)
@@ -29,7 +29,8 @@
 #include "Statistics.hh"
 #include "auto_unit_test.hh"
 #include <boost/test/test_tools.hpp>
-#include <boost/math/special_functions/fpclassify.hpp>
+#include <math.h>
+//#include <boost/math/special_functions/fpclassify.hpp>
 
 #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);