snooze.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/time/snooze.hpp"
00015 #include "../../include/ecl/time/timestamp.hpp"
00016 
00017 /*****************************************************************************
00018 ** Platform Check
00019 *****************************************************************************/
00020 
00021 // Only posix implementation so far
00022 #include <ecl/config.hpp>
00023 #if defined(ECL_IS_POSIX)
00024 
00025 /*****************************************************************************
00026 ** Using
00027 *****************************************************************************/
00028 
00029 using ecl::Duration;
00030 using ecl::Snooze;
00031 using ecl::TimeStamp;
00032 
00033 /*****************************************************************************
00034 ** Tests
00035 *****************************************************************************/
00036 
00037 TEST(SnoozeTests,snoozeConfigured) {
00038         // should check for exceptions here?
00039         Duration duration(0.5);
00040         Snooze snooze;
00041         snooze.period(duration);
00042         Snooze snooze_from_duration(duration);
00043         Snooze snooze_with_validation(duration, true);
00044 
00045     SUCCEED();
00046 }
00047 
00048 TEST(SnoozeTests,setGetPeriod) {
00049         Duration duration(0.5);
00050         Snooze snooze;
00051         snooze.period(duration);
00052     double period = snooze.period();
00053     EXPECT_FLOAT_EQ(0.5,period);
00054 }
00055 
00056 TEST(SnoozeTests,snooze) {
00057         Duration duration(0.5);
00058         Snooze snooze(duration);
00059         TimeStamp start, finish;
00060         snooze.initialise();
00061         snooze();
00062         finish.stamp();
00063         double difference = finish - start;
00064     EXPECT_LT(0.5, difference);
00065     EXPECT_GT(1.0, difference);
00066 }
00067 
00068 #endif /* ECL_IS_POSIX */
00069 
00070 /*****************************************************************************
00071 ** Main program
00072 *****************************************************************************/
00073 
00074 int main(int argc, char **argv) {
00075 
00076     testing::InitGoogleTest(&argc,argv);
00077     return RUN_ALL_TESTS();
00078 }
00079 
00080 


ecl_time
Author(s): Daniel Stonier
autogenerated on Sun Oct 5 2014 23:35:32