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 "PClockNs.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 
void testPClockNs ()
 Test the PClockNs. More...
 
void testPClockNsCoherence ()
 Test the coherence of the PClockNs. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file main.cpp.

41  {
42  testPClockNs();
44  return 0;
45 }
void testPClockNs()
Test the PClockNs.
Definition: main.cpp:15
void testPClockNsCoherence()
Test the coherence of the PClockNs.
Definition: main.cpp:32

References testPClockNs(), and testPClockNsCoherence().

+ Here is the call graph for this function:

◆ testPClockNs()

void testPClockNs ( )

Test the PClockNs.

Definition at line 15 of file main.cpp.

15  {
16  PClockNs clockNs;
17  clockNs.setOffsetTimeNs(0l);
18  data_stream_assert(clockNs.getOffsetTimeNs() == 0l);
19  std::cout << "testPClockNs : " << clockNs.getFullTimeNs() << std::endl;
20  std::cout << "testPClockNs : " << clockNs.getDateNs() << std::endl;
21  std::cout << "testPClockNs : " << clockNs.getDateCompactNs() << std::endl;
22  data_stream_assert(clockNs.getFullTimeNs() != 0l);
23  data_stream_assert(clockNs.getDateNs() != "");
24 
25  PClockNs otherClock(clockNs), thirdClock;
26  thirdClock = clockNs;
27  data_stream_assert(otherClock.getOffsetTimeNs() == 0l);
28  data_stream_assert(thirdClock.getOffsetTimeNs() == 0l);
29 }
Nanosecond clock.
Definition: PClockNs.h:16
std::string getDateCompactNs() const
Get the date at nanosecond precision (even if it is not precise at the nanosecond scale,...
Definition: PClockNs.cpp:103
std::time_t getOffsetTimeNs() const
Get the offset in nanoseconds of the current clock.
Definition: PClockNs.cpp:78
std::time_t getFullTimeNs() const
Get the full time in nanoseconds.
Definition: PClockNs.cpp:85
void setOffsetTimeNs(std::time_t offsetTimeNs)
Set the offset in nanoseconds of the current clock.
Definition: PClockNs.cpp:71
std::string getDateNs() const
Get the date at nanosecond precision (even if it is not precise at the nanosecond scale,...
Definition: PClockNs.cpp:96
#define data_stream_assert(isOk)

References data_stream_assert, PClockNs::getDateCompactNs(), PClockNs::getDateNs(), PClockNs::getFullTimeNs(), PClockNs::getOffsetTimeNs(), and PClockNs::setOffsetTimeNs().

Referenced by main().

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

◆ testPClockNsCoherence()

void testPClockNsCoherence ( )

Test the coherence of the PClockNs.

Definition at line 32 of file main.cpp.

32  {
33  PClockNs clockNs;
34  for(size_t i(0lu); i < 100lu; ++i){
35  std::time_t currentTime = clockNs.getFullTimeNs();
36  std::cerr << "i = " << std::setfill('0') << std::setw(3) << i << ", time = " << currentTime << ", date = '"<<phoenix_dateNs(currentTime)<<"'" << std::endl;
37  usleep(100);
38  }
39 }
std::string phoenix_dateNs(std::time_t currentDateNs, const char *format)
Convert a given date in nanosecond into a text date.
Definition: PClockNs.cpp:15

References PClockNs::getFullTimeNs(), and phoenix_dateNs().

Referenced by main().

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