blob: dbbf04d2c6c7750f560aba29f098246beeed9f59 [file] [log] [blame]
Ed Tanous796ba932020-08-02 04:29:21 +00001#pragma once
2
3#include <boost/asio/io_context.hpp>
4#include <boost/asio/ip/tcp.hpp>
5#include <boost/beast/_experimental/test/stream.hpp>
6
7namespace crow
8{
9
10/*
11A test class that simulates a socket by wrapping the beast test stream
12
13Additionally it adds remote_endpoint to allow testing of TCP-specific behaviors
14*/
15struct TestStream : public boost::beast::test::stream
16{
17 explicit TestStream(boost::asio::io_context& io) :
18 boost::beast::test::stream(io)
19 {}
20
21 using endpoint = boost::asio::ip::tcp::endpoint;
22 // NOLINTNEXTLINE(readability-identifier-naming)
23 static endpoint remote_endpoint(boost::system::error_code& ec)
24 {
25 ec = {};
26 return {};
27 }
28};
29
30} // namespace crow