-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_events.cpp
More file actions
64 lines (56 loc) · 1.1 KB
/
Copy pathtest_events.cpp
File metadata and controls
64 lines (56 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Created by fbdtemme on 8/17/20.
//
#include <catch2/catch.hpp>
#include <bencode/traits/all.hpp>
#include "bencode/bvalue.hpp"
#include <bencode/events/debug_to.hpp>
#include <sstream>
namespace bc = bencode;
static const bc::bvalue b{
{"a", 1},
{"b", 1u},
{"d", false},
{"e", "string"},
{"f", std::vector{1, 2, 3, 4}}
};
constexpr std::string_view b_events =
R"(begin dict (size=5)
string (const&) (size=1, value="a")
dict key
integer (1)
dict value
string (const&) (size=1, value="b")
dict key
integer (1)
dict value
string (const&) (size=1, value="d")
dict key
integer (0)
dict value
string (const&) (size=1, value="e")
dict key
string (const&) (size=6, value="string")
dict value
string (const&) (size=1, value="f")
dict key
begin list (size=4)
integer (1)
list item
integer (2)
list item
integer (3)
list item
integer (4)
list item
end list
dict value
end dict
)";
TEST_CASE("producing events from bvalue", "[bvalue][events]")
{
std::ostringstream os {};
auto consumer = bc::events::debug_to(os);
bc::connect(consumer, b);
CHECK(os.str() == b_events);
}