userver: userver/dump/operations_mock.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
operations_mock.hpp
1#pragma once
2
3#include <userver/dump/operations.hpp>
4
5USERVER_NAMESPACE_BEGIN
6
7namespace dump {
8
9/// A `Writer` that appends to a string buffer (used in tests)
10class MockWriter final : public Writer {
11 public:
12 /// Creates a `MockWriter` with an empty buffer
13 MockWriter();
14
15 void Finish() override;
16
17 /// Extracts the built string, leaving the Writer in a valid but unspecified
18 /// state
19 std::string Extract() &&;
20
21 private:
22 void WriteRaw(std::string_view data) override;
23
24 std::string data_;
25};
26
27/// A `Reader` that reads from a string buffer (used in tests)
28class MockReader final : public Reader {
29 public:
30 /// Creates a `PipeReader` that references the given buffer
31 explicit MockReader(std::string data);
32
33 void Finish() override;
34
35 private:
36 std::string_view ReadRaw(std::size_t max_size) override;
37
38 std::string data_;
39 std::string_view unread_data_;
40};
41
42} // namespace dump
43
44USERVER_NAMESPACE_END