ndn::time::UnitTestClock< BaseClock, ClockTraits > Class Template Reference

Clock that can be used in unit tests for time-dependent tests independent of wall clock. More...

#include <ndn-cxx/util/time-unit-test-clock.hpp>

+ Inheritance diagram for ndn::time::UnitTestClock< BaseClock, ClockTraits >:
+ Collaboration diagram for ndn::time::UnitTestClock< BaseClock, ClockTraits >:

Public Member Functions

 UnitTestClock (nanoseconds startTime=ClockTraits::getDefaultStartTime())
 
void advance (nanoseconds duration)
 Advance unit test clock by duration. More...
 
BaseClock::time_point getNow () const override
 
std::string getSince () const override
 
void setNow (nanoseconds timeSinceEpoch)
 Explicitly set clock to timeSinceEpoch. More...
 
BaseClock::duration toWaitDuration (typename BaseClock::duration d) const override
 

Detailed Description

template<class BaseClock, class ClockTraits = UnitTestClockTraits<BaseClock>>
class ndn::time::UnitTestClock< BaseClock, ClockTraits >

Clock that can be used in unit tests for time-dependent tests independent of wall clock.

This clock should be explicitly advanced with UnitTestClock<BaseClock>::advance() or set with UnitTestClock<BaseClock>::setNow() methods.

Note
Default start time is determined by UnitTestClockTraits

Definition at line 73 of file time-unit-test-clock.hpp.

Constructor & Destructor Documentation

template<class BaseClock , class ClockTraits >
ndn::time::UnitTestClock< BaseClock, ClockTraits >::UnitTestClock ( nanoseconds  startTime = ClockTraits::getDefaultStartTime())
explicit

Definition at line 32 of file time-unit-test-clock.cpp.

Member Function Documentation

template<class BaseClock , class ClockTraits >
void ndn::time::UnitTestClock< BaseClock, ClockTraits >::advance ( nanoseconds  duration)

Advance unit test clock by duration.

Definition at line 60 of file time-unit-test-clock.cpp.

template<class BaseClock , class ClockTraits >
BaseClock::time_point ndn::time::UnitTestClock< BaseClock, ClockTraits >::getNow ( ) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 46 of file time-unit-test-clock.cpp.

template<class BaseClock , class ClockTraits >
std::string ndn::time::UnitTestClock< BaseClock, ClockTraits >::getSince ( ) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 39 of file time-unit-test-clock.cpp.

template<class BaseClock , class ClockTraits >
void ndn::time::UnitTestClock< BaseClock, ClockTraits >::setNow ( nanoseconds  timeSinceEpoch)

Explicitly set clock to timeSinceEpoch.

Definition at line 81 of file time-unit-test-clock.cpp.

template<class BaseClock , class ClockTraits >
BaseClock::duration ndn::time::UnitTestClock< BaseClock, ClockTraits >::toWaitDuration ( typename BaseClock::duration  d) const
overridevirtual

Implements ndn::time::CustomClock< BaseClock >.

Definition at line 53 of file time-unit-test-clock.cpp.