Ed Tanous | 796ba93 | 2020-08-02 04:29:21 +0000 | [diff] [blame] | 1 | #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 | |
| 7 | namespace crow |
| 8 | { |
| 9 | |
| 10 | /* |
| 11 | A test class that simulates a socket by wrapping the beast test stream |
| 12 | |
| 13 | Additionally it adds remote_endpoint to allow testing of TCP-specific behaviors |
| 14 | */ |
| 15 | struct 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 |