Files
boost_beast/test/beast/websocket/stream.cpp

147 lines
3.3 KiB
C++
Raw Normal View History

//
2017-08-21 14:45:58 -07:00
// Copyright (w) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
2017-07-20 13:40:34 -07:00
// Official repository: https://github.com/boostorg/beast
//
// Test that header file is self-contained.
2017-07-20 13:40:34 -07:00
#include <boost/beast/websocket/stream.hpp>
2017-08-24 06:21:30 -07:00
#include "test.hpp"
2017-07-20 13:40:34 -07:00
namespace boost {
namespace beast {
namespace websocket {
2017-08-24 06:21:30 -07:00
class stream_test : public websocket_test_suite
{
public:
2017-08-22 18:08:56 -07:00
void
testOptions()
{
{
std::seed_seq ss{42};
seed_prng(ss);
}
stream<test::stream> ws{ioc_};
2017-08-22 18:08:56 -07:00
ws.auto_fragment(true);
ws.write_buffer_size(2048);
ws.binary(false);
ws.read_message_max(1 * 1024 * 1024);
try
{
ws.write_buffer_size(7);
fail();
}
catch(std::exception const&)
{
pass();
}
ws.secure_prng(true);
ws.secure_prng(false);
auto const bad =
[&](permessage_deflate const& pmd)
{
stream<test::stream> ws{ioc_};
try
{
ws.set_option(pmd);
fail("", __FILE__, __LINE__);
}
catch(std::exception const&)
{
pass();
}
};
{
permessage_deflate pmd;
pmd.server_max_window_bits = 16;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.server_max_window_bits = 8;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.client_max_window_bits = 16;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.client_max_window_bits = 8;
bad(pmd);
}
2017-07-29 17:47:04 -07:00
{
permessage_deflate pmd;
pmd.compLevel = -1;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.compLevel = 10;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.memLevel = 0;
bad(pmd);
}
{
permessage_deflate pmd;
pmd.memLevel = 10;
bad(pmd);
}
}
void
run() override
{
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(std::is_constructible<
stream<test::stream>, boost::asio::io_context&>::value);
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(std::is_move_constructible<
2017-08-24 06:21:30 -07:00
stream<test::stream>>::value);
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(std::is_move_assignable<
2017-08-24 06:21:30 -07:00
stream<test::stream>>::value);
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(std::is_constructible<
2017-08-24 06:21:30 -07:00
stream<test::stream&>, test::stream&>::value);
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(std::is_move_constructible<
2017-08-24 06:21:30 -07:00
stream<test::stream&>>::value);
2016-05-04 11:06:17 -04:00
2017-05-23 12:33:31 -07:00
BOOST_STATIC_ASSERT(! std::is_move_assignable<
2017-08-24 06:21:30 -07:00
stream<test::stream&>>::value);
log << "sizeof(websocket::stream_base<true>) == " <<
sizeof(websocket::detail::stream_base<true>) << std::endl;
2016-06-10 15:48:39 -04:00
log << "sizeof(websocket::stream) == " <<
sizeof(websocket::stream<test::stream&>) << std::endl;
testOptions();
}
};
2017-08-01 17:01:57 -07:00
BEAST_DEFINE_TESTSUITE(beast,websocket,stream);
} // websocket
} // beast
2017-07-20 13:40:34 -07:00
} // boost