23 #include "ndn-cxx/util/impl/steady-timer.hpp"
31 template<
class BaseClock,
class ClockTraits>
33 : m_currentTime(startTime)
37 template<
class BaseClock,
class ClockTraits>
41 return " since unit test beginning";
44 template<
class BaseClock,
class ClockTraits>
45 typename BaseClock::time_point
48 return typename BaseClock::time_point(duration_cast<typename BaseClock::duration>(m_currentTime));
51 template<
class BaseClock,
class ClockTraits>
58 template<
class BaseClock,
class ClockTraits>
75 boost::asio::wait_traits<steady_clock>::to_wait_duration(
duration) +
79 template<
class BaseClock,
class ClockTraits>
83 BOOST_ASSERT(!BaseClock::is_steady || timeSinceEpoch >= m_currentTime);
85 m_currentTime = timeSinceEpoch;
88 auto delta = timeSinceEpoch - m_currentTime;
90 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