userver
C++ Async Framework
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
Toggle main menu visibility
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
All results
test_helpers.hpp
1
#
pragma
once
2
3
#
include
<
utility
>
4
5
#
include
<
userver
/
utest
/
utest
.
hpp
>
6
#
include
<
userver
/
utils
/
fast_scope_guard
.
hpp
>
7
8
#
include
<
userver
/
dump
/
operations_mock
.
hpp
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
dump
{
13
14
/// Converts to binary using `Write(Writer&, const T&)`
15
template
<
typename
T>
16
std
::
string
ToBinary
(
const
T& value) {
17
MockWriter writer;
18
writer.Write(value);
19
return
std::move(writer).Extract();
20
}
16
std
::
string
ToBinary
(
const
T& value) {
…
}
21
22
/// Converts from binary using `Read(Reader&, To<T>)`
23
template
<
typename
T>
24
std
::
remove_const_t
<
T
>
FromBinary
(std::string data) {
25
MockReader reader(std::move(data));
26
auto
value = reader.Read<std::remove_const_t<T>>();
27
reader.Finish();
28
return
value;
29
}
24
std
::
remove_const_t
<
T
>
FromBinary
(std::string data) {
…
}
30
31
/// Write a value to a cache dump and immediately read it back. If `Write` and
32
/// `Read` are implemented correctly, the result should be equal to the original
33
/// value.
34
template
<
typename
T>
35
void
TestWriteReadCycle
(
const
T& original) {
36
MockReader reader(
dump
::ToBinary(original));
37
T after_cycle = reader.Read<T>();
38
reader.Finish();
39
EXPECT_EQ(after_cycle, original);
40
}
35
void
TestWriteReadCycle
(
const
T& original) {
…
}
41
42
}
// namespace dump
43
44
USERVER_NAMESPACE_END
Docs version:
v1.0
,
v2.0
,
trunk/develop
userver
dump
test_helpers.hpp
Generated on Wed Apr 30 2025 15:52:48 for userver by
Doxygen
1.13.2