time_data.cpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Includes
00010 *****************************************************************************/
00011 
00012 #include <cstdlib>
00013 #include <gtest/gtest.h>
00014 #include "../../include/ecl/time/time_data.hpp"
00015 
00016 /*****************************************************************************
00017 ** Using
00018 *****************************************************************************/
00019 
00020 using ecl::Duration;
00021 using ecl::TimeData;
00022 
00023 /*****************************************************************************
00024 ** Tests
00025 *****************************************************************************/
00026 
00027 TEST(TimeDataTests,container) {
00028     TimeData time_data;
00029     Duration duration;
00030     duration.stamp(1,0);
00031     time_data.push_back(duration);
00032     time_data.push_back(duration);
00033     time_data.clear();
00034     SUCCEED();
00035 }
00036 
00037 TEST(TimeDataTests,statistics) {
00038     TimeData time_data;
00039     Duration duration;
00040     duration.stamp(1,0);
00041     time_data.push_back(duration);
00042     duration.stamp(2,0);
00043     time_data.push_back(duration);
00044     double avg = time_data.average();
00045     EXPECT_LT(1.49,avg); // Allow for some roundoff error.
00046     EXPECT_GT(1.51,avg);
00047     double std_dev = time_data.stdDev();
00048     EXPECT_LT(0.49,std_dev); // Allow for some roundoff error.
00049     EXPECT_GT(0.51,std_dev);
00050     double variance = time_data.variance();
00051     EXPECT_LT(0.24,variance); // Allow for some roundoff error.
00052     EXPECT_GT(0.26,variance);
00053 }
00054 /*****************************************************************************
00055 ** Main program
00056 *****************************************************************************/
00057 
00058 int main(int argc, char **argv) {
00059 
00060     testing::InitGoogleTest(&argc,argv);
00061     return RUN_ALL_TESTS();
00062 }


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:17