Branch Coverage

t/deflate/deflate-frames.cc
Criterion Covered Total %
branch 897 2088 42.9


line true false branch
13 14 5 for (const string& s : range) r += s;
14 0 for (const string& s : range) r += s;
8 4 for (const string& s : range) r += s;
8 0 for (const string& s : range) r += s;
18 7 for (const string& s : range) r += s;
18 0 for (const string& s : range) r += s;
21 20 0 ServerParser server;
22 20 0 server.configure(cfg);
23 20 0 ClientParser client;
25 20 0 ConnectRequestSP connect_request(new ConnectRequest());
20 0 ConnectRequestSP connect_request(new ConnectRequest());
26 20 0 connect_request->uri = new URI("ws://crazypanda.ru");
20 0 connect_request->uri = new URI("ws://crazypanda.ru");
27 20 0 connect_request->ws_key = "dGhlIHNhbXBsZSBub25jZQ==";
29 20 0 connect_request->ws_protocol = "ws";
30 20 0 auto client_request = client.connect_request(connect_request);
32 20 0 REQUIRE((bool)server.accept(client_request));
20 0 REQUIRE((bool)server.accept(client_request));
20 0 REQUIRE((bool)server.accept(client_request));
20 0 REQUIRE((bool)server.accept(client_request));
20 0 REQUIRE((bool)server.accept(client_request));
0 0 REQUIRE((bool)server.accept(client_request));
0 0 REQUIRE((bool)server.accept(client_request));
33 20 0 auto server_reply = server.accept_response();
34 20 0 client.connect(server_reply);
36 20 0 REQUIRE(server.established());
20 0 REQUIRE(server.established());
20 0 REQUIRE(server.established());
20 0 REQUIRE(server.established());
0 0 REQUIRE(server.established());
0 0 REQUIRE(server.established());
37 20 0 REQUIRE(client.established());
20 0 REQUIRE(client.established());
20 0 REQUIRE(client.established());
20 0 REQUIRE(client.established());
0 0 REQUIRE(client.established());
0 0 REQUIRE(client.established());
38 20 0 REQUIRE(server.is_deflate_active());
20 0 REQUIRE(server.is_deflate_active());
20 0 REQUIRE(server.is_deflate_active());
20 0 REQUIRE(server.is_deflate_active());
0 0 REQUIRE(server.is_deflate_active());
0 0 REQUIRE(server.is_deflate_active());
39 20 0 REQUIRE(client.is_deflate_active());
20 0 REQUIRE(client.is_deflate_active());
20 0 REQUIRE(client.is_deflate_active());
20 0 REQUIRE(client.is_deflate_active());
0 0 REQUIRE(client.is_deflate_active());
0 0 REQUIRE(client.is_deflate_active());
41 20 0 SECTION("FrameBuffer") {
20 0 SECTION("FrameBuffer") {
20 0 SECTION("FrameBuffer") {
20 0 SECTION("FrameBuffer") {
4 16 SECTION("FrameBuffer") {
43 4 0 SECTION("send (iterator)") {
4 0 SECTION("send (iterator)") {
4 0 SECTION("send (iterator)") {
4 0 SECTION("send (iterator)") {
1 3 SECTION("send (iterator)") {
45 1 0 fragments.push_back("hello");
46 1 0 fragments.push_back(" world");
47 1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
48 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
49 1 0 auto messages_it = client.get_messages(data_string);
50 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
51 1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
54 4 0 SECTION("send (iterator, empty)") {
4 0 SECTION("send (iterator, empty)") {
4 0 SECTION("send (iterator, empty)") {
4 0 SECTION("send (iterator, empty)") {
1 3 SECTION("send (iterator, empty)") {
56 1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
57 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
58 1 0 auto messages_it = client.get_messages(data_string);
59 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
60 1 0 REQUIRE(messages_it.begin()->payload.empty());
1 0 REQUIRE(messages_it.begin()->payload.empty());
1 0 REQUIRE(messages_it.begin()->payload.empty());
1 0 REQUIRE(messages_it.begin()->payload.empty());
1 0 REQUIRE(messages_it.begin()->payload.empty());
1 0 REQUIRE(messages_it.begin()->payload.empty());
0 0 REQUIRE(messages_it.begin()->payload.empty());
0 0 REQUIRE(messages_it.begin()->payload.empty());
63 4 0 SECTION("send (iterator with holes)") {
4 0 SECTION("send (iterator with holes)") {
4 0 SECTION("send (iterator with holes)") {
4 0 SECTION("send (iterator with holes)") {
1 3 SECTION("send (iterator with holes)") {
65 1 0 fragments.push_back("");
66 1 0 fragments.push_back("hello");
67 1 0 fragments.push_back("");
68 1 0 fragments.push_back(" world");
69 1 0 fragments.push_back("");
70 1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
71 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
72 1 0 auto messages_it = client.get_messages(data_string);
73 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
74 1 0 auto it = messages_it.begin();
75 1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
76 1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
0 0 REQUIRE(it->payload[0] == "hello world");
0 0 REQUIRE(it->payload[0] == "hello world");
79 4 0 SECTION("send with zero shared-capacity last buff") {
4 0 SECTION("send with zero shared-capacity last buff") {
4 0 SECTION("send with zero shared-capacity last buff") {
4 0 SECTION("send with zero shared-capacity last buff") {
1 3 SECTION("send with zero shared-capacity last buff") {
105 1 0 fragments.emplace_back(reinterpret_cast(buff), sizeof(buff));
108 1 0 fragments.emplace_back(sso_23.substr(23, 0));
1 0 fragments.emplace_back(sso_23.substr(23, 0));
109 1 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
1 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
1 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
1 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
1 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
0 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
0 0 REQUIRE(bool(fragments.back().shared_buf())); // bool to prevent Catch printing data
110 1 0 REQUIRE(fragments.back().shared_capacity() == 0);
1 0 REQUIRE(fragments.back().shared_capacity() == 0);
1 0 REQUIRE(fragments.back().shared_capacity() == 0);
1 0 REQUIRE(fragments.back().shared_capacity() == 0);
1 0 REQUIRE(fragments.back().shared_capacity() == 0);
1 0 REQUIRE(fragments.back().shared_capacity() == 0);
0 0 REQUIRE(fragments.back().shared_capacity() == 0);
0 0 REQUIRE(fragments.back().shared_capacity() == 0);
111 1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
1 0 auto data = server.start_message(DeflateFlag::YES).send(fragments.begin(), fragments.end(), true);
112 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
113 1 0 auto messages_it = client.get_messages(data_string);
114 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
115 1 0 auto it = messages_it.begin();
116 1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
117 1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
1 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
0 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
0 0 REQUIRE(it->payload[0].size() >= sizeof(buff));
122 20 0 SECTION("MessageBuilder") {
20 0 SECTION("MessageBuilder") {
20 0 SECTION("MessageBuilder") {
20 0 SECTION("MessageBuilder") {
9 11 SECTION("MessageBuilder") {
123 9 0 SECTION("MessageBuilder::send (fragmented message iterator)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator)") {
1 8 SECTION("MessageBuilder::send (fragmented message iterator)") {
125 1 0 fragments.push_back("hello");
126 1 0 fragments.push_back(" world");
127 1 0 auto data = server.message().send(fragments.begin(), fragments.end());
128 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
129 1 0 auto messages_it = client.get_messages(data_string);
130 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
131 1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
134 9 0 SECTION("MessageBuilder::send (fragmented message iterator, hole in the middle)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, hole in the middle)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, hole in the middle)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, hole in the middle)") {
1 8 SECTION("MessageBuilder::send (fragmented message iterator, hole in the middle)") {
136 1 0 fragments.push_back("hello");
137 1 0 fragments.push_back("");
138 1 0 fragments.push_back("");
139 1 0 fragments.push_back(" world");
140 1 0 auto data = server.message().send(fragments.begin(), fragments.end());
141 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
142 1 0 auto messages_it = client.get_messages(data_string);
143 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
144 1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
1 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
0 0 REQUIRE(messages_it.begin()->payload[0] == "hello world");
147 9 0 SECTION("MessageBuilder::send (empty string)") {
9 0 SECTION("MessageBuilder::send (empty string)") {
9 0 SECTION("MessageBuilder::send (empty string)") {
9 0 SECTION("MessageBuilder::send (empty string)") {
1 8 SECTION("MessageBuilder::send (empty string)") {
149 1 0 auto data = server.message().send(item);
150 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
151 1 0 auto messages_it = client.get_messages(data_string);
152 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
153 1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
0 0 REQUIRE(messages_it.begin()->payload.size() == 0);
0 0 REQUIRE(messages_it.begin()->payload.size() == 0);
156 9 0 SECTION("MessageBuilder::send (fragmented message iterator, empty)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, empty)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, empty)") {
9 0 SECTION("MessageBuilder::send (fragmented message iterator, empty)") {
1 8 SECTION("MessageBuilder::send (fragmented message iterator, empty)") {
158 1 0 fragments.push_back("");
159 1 0 auto data = server.message().send(fragments.begin(), fragments.end());
160 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
161 1 0 auto messages_it = client.get_messages(data_string);
162 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
163 1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
1 0 REQUIRE(messages_it.begin()->payload.size() == 0);
0 0 REQUIRE(messages_it.begin()->payload.size() == 0);
0 0 REQUIRE(messages_it.begin()->payload.size() == 0);
166 9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 1 fragment)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 1 fragment)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 1 fragment)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 1 fragment)") {
1 8 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 1 fragment)") {
170 1 0 fragments1.push_back("hello");
171 1 0 fragments1.push_back(" world!");
172 1 0 pieces.push_back(fragments1);
176 1 0 auto data = builder.deflate(true).send(pieces.begin(), pieces.end());
177 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
178 1 0 REQUIRE(data_string != "hello world!");
1 0 REQUIRE(data_string != "hello world!");
1 0 REQUIRE(data_string != "hello world!");
1 0 REQUIRE(data_string != "hello world!");
1 0 REQUIRE(data_string != "hello world!");
0 0 REQUIRE(data_string != "hello world!");
0 0 REQUIRE(data_string != "hello world!");
179 1 0 auto messages_it = client.get_messages(data_string);
180 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
182 1 0 auto it = messages_it.begin();
183 1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
186 9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments)") {
1 8 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments)") {
190 1 0 fragments1.push_back("hello");
191 1 0 fragments1.push_back(" world!");
192 1 0 pieces.push_back(fragments1);
195 1 0 fragments2.push_back(" Let's do ");
196 1 0 fragments2.push_back("some testing");
197 1 0 pieces.push_back(fragments2);
200 1 0 auto data = builder.deflate(true).send(pieces.begin(), pieces.end());
201 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
202 1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
203 1 0 auto messages_it = client.get_messages(data_string);
204 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
206 1 0 auto it = messages_it.begin();
207 1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
0 0 REQUIRE(it->payload.size() == 2);
0 0 REQUIRE(it->payload.size() == 2);
208 1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
209 1 0 REQUIRE(it->payload[1] == " Let's do some testing");
1 0 REQUIRE(it->payload[1] == " Let's do some testing");
1 0 REQUIRE(it->payload[1] == " Let's do some testing");
1 0 REQUIRE(it->payload[1] == " Let's do some testing");
1 0 REQUIRE(it->payload[1] == " Let's do some testing");
1 0 REQUIRE(it->payload[1] == " Let's do some testing");
0 0 REQUIRE(it->payload[1] == " Let's do some testing");
0 0 REQUIRE(it->payload[1] == " Let's do some testing");
212 9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, last empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, last empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, last empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, last empty)") {
1 8 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, last empty)") {
216 1 0 fragments1.push_back("hello");
217 1 0 fragments1.push_back(" world!");
218 1 0 pieces.push_back(fragments1);
221 1 0 pieces.push_back(fragments2);
224 1 0 auto data = builder.deflate(true).send(pieces.begin(), pieces.end());
225 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
226 1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
227 1 0 auto messages_it = client.get_messages(data_string);
228 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
230 1 0 auto it = messages_it.begin();
231 1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
1 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
0 0 REQUIRE(it->payload.size() == 1);
232 1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
1 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
0 0 REQUIRE(it->payload[0] == "hello world!");
235 9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 4 fragments, empty middle)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 4 fragments, empty middle)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 4 fragments, empty middle)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 4 fragments, empty middle)") {
1 8 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 4 fragments, empty middle)") {
239 1 0 fragments1.push_back("hello");
240 1 0 fragments1.push_back(" world");
241 1 0 pieces.push_back(fragments1);
244 1 0 pieces.push_back(fragments2);
247 1 0 fragments3.push_back("");
248 1 0 pieces.push_back(fragments3);
251 1 0 fragments4.push_back("!");
252 1 0 pieces.push_back(fragments4);
255 1 0 auto data = builder.deflate(true).send(pieces.begin(), pieces.end());
256 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
257 1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
258 1 0 auto messages_it = client.get_messages(data_string);
259 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
261 1 0 auto it = messages_it.begin();
262 1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
1 0 REQUIRE(it->payload.size() == 2);
0 0 REQUIRE(it->payload.size() == 2);
0 0 REQUIRE(it->payload.size() == 2);
263 1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
1 0 REQUIRE(it->payload[0] == "hello world");
0 0 REQUIRE(it->payload[0] == "hello world");
0 0 REQUIRE(it->payload[0] == "hello world");
264 1 0 REQUIRE(it->payload[1] == "!");
1 0 REQUIRE(it->payload[1] == "!");
1 0 REQUIRE(it->payload[1] == "!");
1 0 REQUIRE(it->payload[1] == "!");
1 0 REQUIRE(it->payload[1] == "!");
1 0 REQUIRE(it->payload[1] == "!");
0 0 REQUIRE(it->payload[1] == "!");
0 0 REQUIRE(it->payload[1] == "!");
267 9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, both empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, both empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, both empty)") {
9 0 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, both empty)") {
1 8 SECTION("MessageBuilder::send (fragmented multi-frame iterator, 2 fragments, both empty)") {
271 1 0 pieces.push_back(fragments1);
274 1 0 pieces.push_back(fragments2);
277 1 0 auto data = builder.deflate(true).send(pieces.begin(), pieces.end());
278 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
279 1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
1 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
0 0 REQUIRE(data_string.find("hello") == std::string::npos);
280 1 0 auto messages_it = client.get_messages(data_string);
281 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
283 1 0 auto it = messages_it.begin();
284 1 0 REQUIRE(it->payload.empty());
1 0 REQUIRE(it->payload.empty());
1 0 REQUIRE(it->payload.empty());
1 0 REQUIRE(it->payload.empty());
1 0 REQUIRE(it->payload.empty());
0 0 REQUIRE(it->payload.empty());
0 0 REQUIRE(it->payload.empty());
288 20 0 SECTION("empty compressed frame with zero payload") {
20 0 SECTION("empty compressed frame with zero payload") {
20 0 SECTION("empty compressed frame with zero payload") {
20 0 SECTION("empty compressed frame with zero payload") {
2 18 SECTION("empty compressed frame with zero payload") {
290 2 0 REQUIRE(payload.length() == 0);
2 0 REQUIRE(payload.length() == 0);
2 0 REQUIRE(payload.length() == 0);
2 0 REQUIRE(payload.length() == 0);
2 0 REQUIRE(payload.length() == 0);
0 0 REQUIRE(payload.length() == 0);
0 0 REQUIRE(payload.length() == 0);
292 2 0 auto data = server.start_message(DeflateFlag::YES).send(payload, true);
2 0 auto data = server.start_message(DeflateFlag::YES).send(payload, true);
293 2 0 auto it = std::begin(data) + 1;
294 2 0 REQUIRE((*it).length() == 1);
2 0 REQUIRE((*it).length() == 1);
2 0 REQUIRE((*it).length() == 1);
2 0 REQUIRE((*it).length() == 1);
2 0 REQUIRE((*it).length() == 1);
0 0 REQUIRE((*it).length() == 1);
0 0 REQUIRE((*it).length() == 1);
295 2 0 REQUIRE((*it).capacity() >= ((*it).length()));
2 0 REQUIRE((*it).capacity() >= ((*it).length()));
2 0 REQUIRE((*it).capacity() >= ((*it).length()));
2 0 REQUIRE((*it).capacity() >= ((*it).length()));
2 0 REQUIRE((*it).capacity() >= ((*it).length()));
2 0 REQUIRE((*it).capacity() >= ((*it).length()));
0 0 REQUIRE((*it).capacity() >= ((*it).length()));
0 0 REQUIRE((*it).capacity() >= ((*it).length()));
296 2 0 auto data_string = to_string(data);
2 0 auto data_string = to_string(data);
297 2 0 REQUIRE(data_string.length() == 3);
2 0 REQUIRE(data_string.length() == 3);
2 0 REQUIRE(data_string.length() == 3);
2 0 REQUIRE(data_string.length() == 3);
2 0 REQUIRE(data_string.length() == 3);
0 0 REQUIRE(data_string.length() == 3);
0 0 REQUIRE(data_string.length() == 3);
299 2 0 SECTION("zero uncompressed payload") {
2 0 SECTION("zero uncompressed payload") {
2 0 SECTION("zero uncompressed payload") {
2 0 SECTION("zero uncompressed payload") {
1 1 SECTION("zero uncompressed payload") {
300 1 0 auto messages_it = client.get_messages(data_string);
301 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
302 1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
0 0 REQUIRE(messages_it.begin()->payload_length() == 0);
0 0 REQUIRE(messages_it.begin()->payload_length() == 0);
305 2 0 SECTION("non-zero network payload") {
2 0 SECTION("non-zero network payload") {
2 0 SECTION("non-zero network payload") {
2 0 SECTION("non-zero network payload") {
1 1 SECTION("non-zero network payload") {
306 1 0 auto frames_it = client.get_frames(data_string);
307 1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
1 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
0 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
0 0 REQUIRE(std::distance(frames_it.begin(), frames_it.end()) == 1);
308 1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
1 0 REQUIRE(frames_it.begin()->payload_length() == 1);
0 0 REQUIRE(frames_it.begin()->payload_length() == 1);
0 0 REQUIRE(frames_it.begin()->payload_length() == 1);
313 20 0 SECTION("compressed frame with zero payload") {
20 0 SECTION("compressed frame with zero payload") {
20 0 SECTION("compressed frame with zero payload") {
20 0 SECTION("compressed frame with zero payload") {
1 19 SECTION("compressed frame with zero payload") {
315 1 0 REQUIRE(payload.length() == 0);
1 0 REQUIRE(payload.length() == 0);
1 0 REQUIRE(payload.length() == 0);
1 0 REQUIRE(payload.length() == 0);
1 0 REQUIRE(payload.length() == 0);
0 0 REQUIRE(payload.length() == 0);
0 0 REQUIRE(payload.length() == 0);
317 1 0 auto data_string = Frame::compile(fh, payload);
318 1 0 auto messages_it = client.get_messages(data_string);
319 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
320 1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
1 0 REQUIRE(messages_it.begin()->payload_length() == 0);
0 0 REQUIRE(messages_it.begin()->payload_length() == 0);
0 0 REQUIRE(messages_it.begin()->payload_length() == 0);
323 20 0 SECTION("Control compressed frame") {
20 0 SECTION("Control compressed frame") {
20 0 SECTION("Control compressed frame") {
20 0 SECTION("Control compressed frame") {
1 19 SECTION("Control compressed frame") {
326 1 0 auto data_string = Frame::compile(fh, payload);
327 1 0 auto frames_it = client.get_frames(data_string);
328 1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
1 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
0 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
0 0 REQUIRE(frames_it.begin()->error & errc::control_frame_compression);
331 20 0 SECTION("send compressed frame bigger then original") {
20 0 SECTION("send compressed frame bigger then original") {
20 0 SECTION("send compressed frame bigger then original") {
20 0 SECTION("send compressed frame bigger then original") {
1 19 SECTION("send compressed frame bigger then original") {
332 1 0 string payload = encode::decode_base16("8e008f8f8f0090909000919191009292");
333 1 0 string payload_copy = payload;
335 1 0 auto data = server.start_message(DeflateFlag::YES).send(payload, true);
1 0 auto data = server.start_message(DeflateFlag::YES).send(payload, true);
336 1 0 auto it = std::begin(data) + 1;
337 1 0 REQUIRE((*it).length() == 24);
1 0 REQUIRE((*it).length() == 24);
1 0 REQUIRE((*it).length() == 24);
1 0 REQUIRE((*it).length() == 24);
1 0 REQUIRE((*it).length() == 24);
0 0 REQUIRE((*it).length() == 24);
0 0 REQUIRE((*it).length() == 24);
338 1 0 auto data_string = to_string(data);
1 0 auto data_string = to_string(data);
339 1 0 auto messages_it = client.get_messages(data_string);
340 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
341 1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
342 1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
1 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
0 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
0 0 REQUIRE(messages_it.begin()->payload[0] == payload_copy);
345 20 0 SECTION("SRV-1236") {
20 0 SECTION("SRV-1236") {
20 0 SECTION("SRV-1236") {
20 0 SECTION("SRV-1236") {
1 19 SECTION("SRV-1236") {
346 1 0 SECTION("buggy sample (does work)") {
1 0 SECTION("buggy sample (does work)") {
1 0 SECTION("buggy sample (does work)") {
1 0 SECTION("buggy sample (does work)") {
1 0 SECTION("buggy sample (does work)") {
348 1 0 string payload = encode::decode_base64(data_sample);
350 1 0 auto data_string = Frame::compile(fh, payload).append(payload);
1 0 auto data_string = Frame::compile(fh, payload).append(payload);
1 0 auto data_string = Frame::compile(fh, payload).append(payload);
351 1 0 auto messages_it = server.get_messages(data_string);
352 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
353 1 0 REQUIRE(!messages_it.begin()->error);
1 0 REQUIRE(!messages_it.begin()->error);
1 0 REQUIRE(!messages_it.begin()->error);
1 0 REQUIRE(!messages_it.begin()->error);
1 0 REQUIRE(!messages_it.begin()->error);
1 0 REQUIRE(!messages_it.begin()->error);
0 0 REQUIRE(!messages_it.begin()->error);
0 0 REQUIRE(!messages_it.begin()->error);
357 20 0 SECTION("zlib test") {
20 0 SECTION("zlib test") {
20 0 SECTION("zlib test") {
20 0 SECTION("zlib test") {
1 19 SECTION("zlib test") {
358 1 0 string payload = encode::decode_base16("8e008f8f8f0090909000919191009292");
374 1 0 auto r = deflateInit2(&tx_stream1, -1, Z_DEFLATED, -1 * 15, 8, Z_DEFAULT_STRATEGY);
375 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
377 1 0 tx_stream1.next_in = reinterpret_cast(payload.buf());
381 1 0 r = deflate(&tx_stream1, Z_SYNC_FLUSH);
382 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
383 1 0 REQUIRE(tx_stream1.total_out == 23);
1 0 REQUIRE(tx_stream1.total_out == 23);
1 0 REQUIRE(tx_stream1.total_out == 23);
1 0 REQUIRE(tx_stream1.total_out == 23);
1 0 REQUIRE(tx_stream1.total_out == 23);
0 0 REQUIRE(tx_stream1.total_out == 23);
0 0 REQUIRE(tx_stream1.total_out == 23);
391 1 0 r = deflateInit2(&tx_stream2, -1, Z_DEFLATED, -1 * 15, 8, Z_DEFAULT_STRATEGY);
392 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
393 1 0 REQUIRE(tx_stream1.avail_out !=0);
1 0 REQUIRE(tx_stream1.avail_out !=0);
1 0 REQUIRE(tx_stream1.avail_out !=0);
1 0 REQUIRE(tx_stream1.avail_out !=0);
1 0 REQUIRE(tx_stream1.avail_out !=0);
0 0 REQUIRE(tx_stream1.avail_out !=0);
0 0 REQUIRE(tx_stream1.avail_out !=0);
395 1 0 tx_stream2.next_in = reinterpret_cast(payload.buf());
399 1 0 r = deflate(&tx_stream2, Z_SYNC_FLUSH);
400 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
401 1 0 REQUIRE(tx_stream2.total_out == 23);
1 0 REQUIRE(tx_stream2.total_out == 23);
1 0 REQUIRE(tx_stream2.total_out == 23);
1 0 REQUIRE(tx_stream2.total_out == 23);
1 0 REQUIRE(tx_stream2.total_out == 23);
0 0 REQUIRE(tx_stream2.total_out == 23);
0 0 REQUIRE(tx_stream2.total_out == 23);
402 1 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
1 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
1 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
1 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
1 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
0 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
0 0 REQUIRE(tx_stream2.avail_out == 0); // !!! ???
405 1 0 r = deflate(&tx_stream2, Z_SYNC_FLUSH);
406 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
416 1 0 r = inflateInit2(&rx_stream1, -1 * 15);
417 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
423 1 0 r = inflate(&rx_stream1, Z_SYNC_FLUSH);
424 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
432 1 0 r = inflateInit2(&rx_stream2, -1 * 15);
433 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
439 1 0 r = inflate(&rx_stream2, Z_SYNC_FLUSH);
440 1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
1 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
0 0 REQUIRE(r == Z_OK);
442 1 0 deflateEnd(&tx_stream1);
443 1 0 deflateEnd(&tx_stream2);
444 1 0 inflateEnd(&rx_stream1);
445 1 0 inflateEnd(&rx_stream2);
454 2 0 ServerParser server;
455 2 0 server.configure(cfg);
456 2 0 ClientParser client;
458 2 0 ConnectRequestSP connect_request(new ConnectRequest());
2 0 ConnectRequestSP connect_request(new ConnectRequest());
459 2 0 connect_request->uri = new URI("ws://crazypanda.ru");
2 0 connect_request->uri = new URI("ws://crazypanda.ru");
460 2 0 connect_request->ws_key = "dGhlIHNhbXBsZSBub25jZQ==";
462 2 0 connect_request->ws_protocol = "ws";
463 2 0 auto client_request = client.connect_request(connect_request);
465 2 0 REQUIRE((bool)server.accept(client_request));
2 0 REQUIRE((bool)server.accept(client_request));
2 0 REQUIRE((bool)server.accept(client_request));
2 0 REQUIRE((bool)server.accept(client_request));
2 0 REQUIRE((bool)server.accept(client_request));
0 0 REQUIRE((bool)server.accept(client_request));
0 0 REQUIRE((bool)server.accept(client_request));
466 2 0 auto server_reply = server.accept_response();
467 2 0 client.connect(server_reply);
469 2 0 REQUIRE(server.established());
2 0 REQUIRE(server.established());
2 0 REQUIRE(server.established());
2 0 REQUIRE(server.established());
0 0 REQUIRE(server.established());
0 0 REQUIRE(server.established());
470 2 0 REQUIRE(client.established());
2 0 REQUIRE(client.established());
2 0 REQUIRE(client.established());
2 0 REQUIRE(client.established());
0 0 REQUIRE(client.established());
0 0 REQUIRE(client.established());
471 2 0 REQUIRE(server.is_deflate_active());
2 0 REQUIRE(server.is_deflate_active());
2 0 REQUIRE(server.is_deflate_active());
2 0 REQUIRE(server.is_deflate_active());
0 0 REQUIRE(server.is_deflate_active());
0 0 REQUIRE(server.is_deflate_active());
472 2 0 REQUIRE(client.is_deflate_active());
2 0 REQUIRE(client.is_deflate_active());
2 0 REQUIRE(client.is_deflate_active());
2 0 REQUIRE(client.is_deflate_active());
0 0 REQUIRE(client.is_deflate_active());
0 0 REQUIRE(client.is_deflate_active());
474 2 0 SECTION("12.1.3 :: false inflate error caused by incorrectly handling Z_BUF_ERROR") {
2 0 SECTION("12.1.3 :: false inflate error caused by incorrectly handling Z_BUF_ERROR") {
2 0 SECTION("12.1.3 :: false inflate error caused by incorrectly handling Z_BUF_ERROR") {
2 0 SECTION("12.1.3 :: false inflate error caused by incorrectly handling Z_BUF_ERROR") {
1 1 SECTION("12.1.3 :: false inflate error caused by incorrectly handling Z_BUF_ERROR") {
480 4 1 };
0 0 };
481 4 1 for(auto it = std::begin(data_samples); it != std::end(data_samples); ++it){
482 4 0 string payload = encode::decode_base64(*it);
484 4 0 auto data_string = Frame::compile(fh, payload).append(payload);
4 0 auto data_string = Frame::compile(fh, payload).append(payload);
4 0 auto data_string = Frame::compile(fh, payload).append(payload);
485 4 0 auto messages_it = server.get_messages(data_string);
486 4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
4 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
487 4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
4 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
491 2 0 SECTION("12.1.11 (no rsv1 flag on 2nd frame == that's correct)") {
2 0 SECTION("12.1.11 (no rsv1 flag on 2nd frame == that's correct)") {
2 0 SECTION("12.1.11 (no rsv1 flag on 2nd frame == that's correct)") {
2 0 SECTION("12.1.11 (no rsv1 flag on 2nd frame == that's correct)") {
1 1 SECTION("12.1.11 (no rsv1 flag on 2nd frame == that's correct)") {
492 1 0 string payload1 = encode::decode_base64("MjAgFQAAAAD//w");
493 1 0 string payload2 = encode::decode_base64("Ih0AAAAA//8");
496 1 0 auto data_string1 = Frame::compile(fh1, payload1).append(payload1);
1 0 auto data_string1 = Frame::compile(fh1, payload1).append(payload1);
1 0 auto data_string1 = Frame::compile(fh1, payload1).append(payload1);
499 1 0 auto data_string2 = Frame::compile(fh2, payload2).append(payload2);
1 0 auto data_string2 = Frame::compile(fh2, payload2).append(payload2);
1 0 auto data_string2 = Frame::compile(fh2, payload2).append(payload2);
500 1 0 auto data_string = data_string1 + data_string2;
502 1 0 auto messages_it = server.get_messages(data_string);
503 1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
1 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
0 0 REQUIRE(std::distance(messages_it.begin(), messages_it.end()) == 1);
504 1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
1 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
0 0 REQUIRE_FALSE(messages_it.begin()->error);
505 1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
1 0 REQUIRE(messages_it.begin()->payload.size() == 2);
0 0 REQUIRE(messages_it.begin()->payload.size() == 2);
0 0 REQUIRE(messages_it.begin()->payload.size() == 2);
506 1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
0 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
0 0 REQUIRE(messages_it.begin()->payload[0] == "00000000000000000000000000000000000000000000000000");
507 1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
1 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
0 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
0 0 REQUIRE(messages_it.begin()->payload[1] == "00000000000000000000000000000000000000000000000000");
510 18 0 }
18 0 }