Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
FakeClock Class Reference

Class that injects a fake progression of time for unit tests. More...

#include <FakeClock.hxx>

Inheritance diagram for FakeClock:
FakeClockContent Singleton< FakeClock >

Public Member Functions

void advance (long long nsec)
 Advances the time returned by os_get_time_monotonic().
 
long long get_time_nsec ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Singleton< FakeClock >
static FakeClockinstance ()
 
static bool exists ()
 
- Private Member Functions inherited from FakeClockContent
 FakeClockContent (long long t)
 
- Private Attributes inherited from FakeClockContent
long long lastTime_
 

Detailed Description

Class that injects a fake progression of time for unit tests.

When this class is created, the time as returned by os_get_time_monotonic() freezes. From that point on time only moves forward when advance() is called.

There can be at most one instance of this class at any time.

Definition at line 62 of file FakeClock.hxx.

Constructor & Destructor Documentation

◆ FakeClock()

FakeClock::FakeClock ( )
inline

Definition at line 65 of file FakeClock.hxx.

Member Function Documentation

◆ advance()

void FakeClock::advance ( long long  nsec)
inline

Advances the time returned by os_get_time_monotonic().

Parameters
nsechow much the time should jump forward (relative to now).

Definition at line 72 of file FakeClock.hxx.

◆ get_time_nsec()

long long FakeClock::get_time_nsec ( )
inline
Returns
the currently set time.

Definition at line 86 of file FakeClock.hxx.


The documentation for this class was generated from the following file: