PhoenixClockMock  2.0.0
Tool to manipulate mock of clock (split, merge and get info)
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include <unistd.h>
9 #include <iomanip>
10 #include <iostream>
11 #include "data_stream_assert.h"
12 #include "phoenix_clock.h"
13 
16 
19 
22  VecTime vecMockTime;
23  vecMockTime.push_back(0l);
24  vecMockTime.push_back(1l);
25  vecMockTime.push_back(2l);
26 
28 }
29 
30 template<class _Clock>
33  _Clock clock;
34  //Let's try in normal mode
35  clock.setMode(PClockMode::NO_MOCK);
36  data_stream_assert(clock.now() != 0l);
37  //Let's play the mock clock
38  clock.setMode(PClockMode::MOCK);
39  data_stream_assert(clock.now() == 0l);
40  data_stream_assert(clock.now() == 1l);
41  data_stream_assert(clock.now() == 2l);
42  //Let's record the real clock
43  clock.setMode(PClockMode::MOCK_RECORD);
44  data_stream_assert(clock.now() != 0l);
45  //Let's replay the real clock
46  clock.setMode(PClockMode::MOCK);
47  data_stream_assert(clock.now() != 0l);
48 }
49 
52  testSpecialisedClock<ClockSecond>();
53  testSpecialisedClock<ClockNanoSecond>();
54 }
55 
56 int main(int argc, char** argv){
58  return 0;
59 }
60 
61 
bool phoenix_saveClockMock(const VecTime &vecTime)
Save the Clock Mock.
Definition: PClockMock.cpp:14
std::vector< time_t > VecTime
Definition: PClockMock.h:12
void testSpecialisedClock()
Definition: main.cpp:31
int main(int argc, char **argv)
Definition: main.cpp:56
PGenericClock< PClockNsBackend, PClockMock > ClockNanoSecond
Definition of the test clock for more precise time.
Definition: main.cpp:18
void testCreateClockMock()
Create a ClockMock ready to use.
Definition: main.cpp:21
PGenericClock< PClockBackend, PClockMock > ClockSecond
Definition of the test clock.
Definition: main.cpp:15
void testGenericClock()
Test the PGenericClock.
Definition: main.cpp:51
Generic clock which can use several backends (real clock backend and a mock of clock)
Definition: PGenericClock.h:17
#define data_stream_assert(isOk)