cumulative_statistics.cpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Includes
00010 *****************************************************************************/
00011 
00012 #include <iostream>
00013 #include <gtest/gtest.h>
00014 #include "../../include/ecl/statistics/cumulative_statistics.hpp"
00015 
00016 /*****************************************************************************
00017 ** Tests
00018 *****************************************************************************/
00019 
00020 TEST(CumulativeStatistics, cumulative) {
00021     std::cout << std::endl;
00022     std::cout << "***********************************************************" << std::endl;
00023     std::cout << "                 Cumulative Statistics" << std::endl;
00024     std::cout << "***********************************************************" << std::endl;
00025     std::cout << std::endl;
00026     ecl::CumulativeStatistics<float> statistics;
00027     std::cout << "Size: " << statistics.size() << std::endl;
00028     std::cout << "  Mean: " << statistics.mean() << std::endl;
00029     std::cout << "  Variance: " << statistics.variance() << std::endl;
00030     EXPECT_FLOAT_EQ(0.0, statistics.size());
00031     EXPECT_FLOAT_EQ(0.0, statistics.mean());
00032     EXPECT_FLOAT_EQ(0.0, statistics.variance());
00033     statistics.push_back(1.0);
00034     std::cout << "Size: " << statistics.size() << std::endl;
00035     std::cout << "  Mean: " << statistics.mean() << std::endl;
00036     std::cout << "  Variance: " << statistics.variance() << std::endl;
00037     EXPECT_FLOAT_EQ(1.0, statistics.size());
00038     EXPECT_FLOAT_EQ(1.0, statistics.mean());
00039     EXPECT_FLOAT_EQ(0.0, statistics.variance());
00040     statistics.push_back(2.0);
00041     statistics.push_back(3.0);
00042     statistics.push_back(4.0);
00043     statistics.push_back(5.0);
00044     std::cout << "Size: " << statistics.size() << std::endl;
00045     std::cout << "  Mean: " << statistics.mean() << std::endl;
00046     std::cout << "  Variance: " << statistics.variance() << std::endl;
00047     EXPECT_FLOAT_EQ(5.0, statistics.size());
00048     EXPECT_FLOAT_EQ(3.0, statistics.mean());
00049     EXPECT_FLOAT_EQ(2.5, statistics.variance());
00050 }
00051 
00052 /*****************************************************************************
00053 ** Main program
00054 *****************************************************************************/
00055 
00056 int main(int argc, char **argv) {
00057 
00058     testing::InitGoogleTest(&argc,argv);
00059     return RUN_ALL_TESTS();
00060 }
00061 
00062 


ecl_statistics
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 21:17:39