Go to the documentation of this file.00001
00008
00009
00010
00011
00012
00013 #include <gtest/gtest.h>
00014 #include "../../include/ecl/time/snooze.hpp"
00015 #include "../../include/ecl/time/timestamp.hpp"
00016
00017
00018
00019
00020
00021
00022 #include <ecl/config.hpp>
00023 #if defined(ECL_IS_POSIX)
00024
00025
00026
00027
00028
00029 using ecl::Duration;
00030 using ecl::Snooze;
00031 using ecl::TimeStamp;
00032
00033
00034
00035
00036
00037 TEST(SnoozeTests,snoozeConfigured) {
00038
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
00069
00070
00071
00072
00073
00074 int main(int argc, char **argv) {
00075
00076 testing::InitGoogleTest(&argc,argv);
00077 return RUN_ALL_TESTS();
00078 }
00079
00080