userver
C++ Async Framework
Loading...
Searching...
No Matches
mock_now.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/mock_now.hpp
4
/// @brief Mocking and getting mocked time values
5
/// @ingroup userver_universal
6
7
#
include
<
chrono
>
8
9
USERVER_NAMESPACE_BEGIN
10
11
namespace
utils::
datetime
{
12
13
/// @cond
14
std::chrono::system_clock::time_point MockNow()
noexcept
;
15
16
std::chrono::steady_clock::time_point MockSteadyNow()
noexcept
;
17
///@endcond
18
19
/// Sets the mocked value for utils::datetime::Now() and
20
/// utils::datetime::SteadyNow().
21
///
22
/// Thread safe.
23
void
MockNowSet
(std::chrono::system_clock::time_point new_mocked_now);
24
25
/// Adds duration to current mocked time point value
26
///
27
/// Thread safe.
28
///
29
/// @throws utils::InvariantError if IsMockNow() returns false.
30
void
MockSleep
(std::chrono::milliseconds duration);
31
32
/// Removes time point mocking for utils::datetime::Now() and
33
/// utils::datetime::SteadyNow().
34
void
MockNowUnset
()
noexcept
;
35
36
/// Returns true if time point is mocked for utils::datetime::Now() and
37
/// utils::datetime::SteadyNow().
38
bool
IsMockNow
()
noexcept
;
39
40
}
// namespace utils::datetime
41
42
USERVER_NAMESPACE_END
userver
utils
mock_now.hpp
Generated on Wed May 15 2024 22:35:12 for userver by
Doxygen
1.10.0