23 #include "ndn-cxx/util/impl/steady-timer.hpp"
30 template<
class BaseClock,
class ClockTraits>
32 : m_currentTime(startTime)
36 template<
class BaseClock,
class ClockTraits>
40 return " since unit test beginning";
43 template<
class BaseClock,
class ClockTraits>
44 typename BaseClock::time_point
47 return typename BaseClock::time_point(duration_cast<typename BaseClock::duration>(m_currentTime));
50 template<
class BaseClock,
class ClockTraits>
57 template<
class BaseClock,
class ClockTraits>
74 boost::asio::wait_traits<steady_clock>::to_wait_duration(
duration) +
78 template<
class BaseClock,
class ClockTraits>
82 BOOST_ASSERT(!BaseClock::is_steady || timeSinceEpoch >= m_currentTime);
84 m_currentTime = timeSinceEpoch;
87 auto delta = timeSinceEpoch - m_currentTime;
89 boost::asio::wait_traits<steady_clock>::to_wait_duration(delta) +
Clock that can be used in unit tests for time-dependent tests independent of wall clock.
void setNow(nanoseconds timeSinceEpoch)
Explicitly set clock to timeSinceEpoch.
std::string getSince() const override
BaseClock::time_point getNow() const override
BaseClock::duration toWaitDuration(typename BaseClock::duration d) const override
void advance(nanoseconds duration)
Advance unit test clock by duration.
UnitTestClock(nanoseconds startTime=ClockTraits::getDefaultStartTime())
::boost::chrono::duration< Rep, Period > duration
::boost::chrono::nanoseconds nanoseconds