PhoenixClockMock  2.0.0
Tool to manipulate mock of clock (split, merge and get info)
main.cpp File Reference
#include <unistd.h>
#include <iomanip>
#include <iostream>
#include "data_stream_assert.h"
#include "phoenix_clock.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Typedefs

typedef PGenericClock< PClockNsBackend, PClockMockClockNanoSecond
 Definition of the test clock for more precise time. More...
 
typedef PGenericClock< PClockBackend, PClockMockClockSecond
 Definition of the test clock. More...
 

Functions

int main (int argc, char **argv)
 
void testCreateClockMock ()
 Create a ClockMock ready to use. More...
 
void testGenericClock ()
 Test the PGenericClock. More...
 
template<class _Clock >
void testSpecialisedClock ()
 

Typedef Documentation

◆ ClockNanoSecond

Definition of the test clock for more precise time.

Definition at line 18 of file main.cpp.

◆ ClockSecond

Definition of the test clock.

Definition at line 15 of file main.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 56 of file main.cpp.

56  {
58  return 0;
59 }
void testGenericClock()
Test the PGenericClock.
Definition: main.cpp:51

References testGenericClock().

+ Here is the call graph for this function:

◆ testCreateClockMock()

void testCreateClockMock ( )

Create a ClockMock ready to use.

Definition at line 21 of file main.cpp.

21  {
22  VecTime vecMockTime;
23  vecMockTime.push_back(0l);
24  vecMockTime.push_back(1l);
25  vecMockTime.push_back(2l);
26 
28 }
bool phoenix_saveClockMock(const VecTime &vecTime)
Save the Clock Mock.
Definition: PClockMock.cpp:14
std::vector< time_t > VecTime
Definition: PClockMock.h:12
#define data_stream_assert(isOk)

References data_stream_assert, and phoenix_saveClockMock().

Referenced by testSpecialisedClock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testGenericClock()

void testGenericClock ( )

Test the PGenericClock.

Definition at line 51 of file main.cpp.

51  {
52  testSpecialisedClock<ClockSecond>();
53  testSpecialisedClock<ClockNanoSecond>();
54 }

Referenced by main().

+ Here is the caller graph for this function:

◆ testSpecialisedClock()

template<class _Clock >
void testSpecialisedClock ( )

Definition at line 31 of file main.cpp.

31  {
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 }
void testCreateClockMock()
Create a ClockMock ready to use.
Definition: main.cpp:21

References data_stream_assert, PClockMode::MOCK, PClockMode::MOCK_RECORD, PClockMode::NO_MOCK, and testCreateClockMock().

+ Here is the call graph for this function: