proxygen
MockClock Struct Reference

Public Types

using duration = std::chrono::steady_clock::duration
 
using time_point = std::chrono::steady_clock::time_point
 
using duration = std::chrono::steady_clock::duration
 
using time_point = std::chrono::steady_clock::time_point
 
using duration = std::chrono::steady_clock::duration
 
using time_point = std::chrono::time_point< MockClock, duration >
 

Public Member Functions

 MOCK_METHOD0 (nowImpl, time_point())
 

Static Public Member Functions

static time_point now ()
 
static time_point now ()
 
static std::shared_ptr< StrictMock< MockClock > > setup ()
 Hold on to the returned shared_ptr until the end of the test. More...
 
static time_point now ()
 

Static Public Attributes

static time_point Now = MockClock::time_point{}
 
static constexpr auto is_steady = true
 
static std::weak_ptr< StrictMock< MockClock > > s_mockClockInstance
 

Detailed Description

MockClock is a bit tricky because we are mocking a static function (now()), so we need to find the corresponding mock instance without extending its scope beyond that of the test. I generally avoid shared_ptr, but a weak_ptr is just the ticket here

Definition at line 27 of file BufferedStatTest.cpp.

Member Typedef Documentation

using MockClock::duration = std::chrono::steady_clock::duration

Definition at line 25 of file QuantileEstimatorTest.cpp.

using MockClock::duration = std::chrono::steady_clock::duration

Definition at line 29 of file BufferedStatTest.cpp.

using MockClock::duration = std::chrono::steady_clock::duration

Definition at line 57 of file MemoryIdlerTest.cpp.

using MockClock::time_point = std::chrono::steady_clock::time_point

Definition at line 26 of file QuantileEstimatorTest.cpp.

using MockClock::time_point = std::chrono::steady_clock::time_point

Definition at line 30 of file BufferedStatTest.cpp.

using MockClock::time_point = std::chrono::time_point<MockClock, duration>

Definition at line 58 of file MemoryIdlerTest.cpp.

Member Function Documentation

MockClock::MOCK_METHOD0 ( nowImpl  ,
time_point()   
)
static time_point MockClock::now ( )
inlinestatic

Definition at line 29 of file QuantileEstimatorTest.cpp.

References Now.

29  {
30  return Now;
31  }
static time_point Now
static time_point MockClock::now ( )
inlinestatic

Definition at line 32 of file BufferedStatTest.cpp.

32  {
33  return Now;
34  }
static time_point Now
static time_point MockClock::now ( )
inlinestatic

Definition at line 69 of file MemoryIdlerTest.cpp.

69  {
70  return s_mockClockInstance.lock()->nowImpl();
71  }
static std::weak_ptr< StrictMock< MockClock > > s_mockClockInstance
static std::shared_ptr<StrictMock<MockClock> > MockClock::setup ( )
inlinestatic

Hold on to the returned shared_ptr until the end of the test.

Definition at line 63 of file MemoryIdlerTest.cpp.

Referenced by TEST().

63  {
64  auto rv = std::make_shared<StrictMock<MockClock>>();
66  return rv;
67  }
static std::weak_ptr< StrictMock< MockClock > > s_mockClockInstance

Member Data Documentation

constexpr auto MockClock::is_steady = true
static

Definition at line 27 of file QuantileEstimatorTest.cpp.

std::weak_ptr< StrictMock< MockClock > > MockClock::s_mockClockInstance
static

Definition at line 73 of file MemoryIdlerTest.cpp.


The documentation for this struct was generated from the following files: