snooze.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Includes
10 *****************************************************************************/
11 
12 //#include <iostream>
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/time/snooze.hpp"
15 #include "../../include/ecl/time/timestamp.hpp"
16 
17 /*****************************************************************************
18 ** Platform Check
19 *****************************************************************************/
20 
21 // Only posix implementation so far
22 #include <ecl/config.hpp>
23 #if defined(ECL_IS_POSIX)
24 
25 /*****************************************************************************
26 ** Using
27 *****************************************************************************/
28 
29 using ecl::Duration;
30 using ecl::Snooze;
31 using ecl::TimeStamp;
32 
33 /*****************************************************************************
34 ** Tests
35 *****************************************************************************/
36 
37 TEST(SnoozeTests,snoozeConfigured) {
38  // should check for exceptions here?
39  Duration duration(0.5);
40  Snooze snooze;
41  snooze.period(duration);
42  Snooze snooze_from_duration(duration);
43  Snooze snooze_with_validation(duration, true);
44 
45  SUCCEED();
46 }
47 
48 TEST(SnoozeTests,setGetPeriod) {
49  Duration duration(0.5);
50  Snooze snooze;
51  snooze.period(duration);
52  double period = snooze.period();
53  EXPECT_FLOAT_EQ(0.5,period);
54 }
55 
56 TEST(SnoozeTests,snooze) {
57  Duration duration(0.5);
58  Snooze snooze(duration);
59  TimeStamp start, finish;
60  snooze.initialise();
61  snooze();
62  finish.stamp();
63  double difference = finish - start;
64  EXPECT_LT(0.5, difference);
65  EXPECT_GT(1.0, difference);
66 }
67 
68 #endif /* ECL_IS_POSIX */
69 
70 /*****************************************************************************
71 ** Main program
72 *****************************************************************************/
73 
74 int main(int argc, char **argv) {
75 
76  testing::InitGoogleTest(&argc,argv);
77  return RUN_ALL_TESTS();
78 }
79 
80 
TEST(TimeDataTests, container)
int main(int argc, char **argv)
Definition: snooze.cpp:74
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:41


ecl_time
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:15