// // Copyright (c) 2016-2019 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) // // Official repository: https://github.com/boostorg/beast // // Test that header file is self-contained. #include #include #include #include namespace boost { namespace beast { namespace http { class serializer_test : public beast::unit_test::suite { public: struct const_body { struct value_type{}; struct writer { using const_buffers_type = net::const_buffer; template writer(header const&, value_type const&); void init(error_code& ec); boost::optional> get(error_code&); }; }; struct mutable_body { struct value_type{}; struct writer { using const_buffers_type = net::const_buffer; template writer(header&, value_type&); void init(error_code& ec); boost::optional> get(error_code&); }; }; BOOST_STATIC_ASSERT(std::is_const< serializer< true, const_body>::value_type>::value); BOOST_STATIC_ASSERT(! std::is_const::value_type>::value); BOOST_STATIC_ASSERT(std::is_constructible< serializer, message &>::value); BOOST_STATIC_ASSERT(std::is_constructible< serializer, message const&>::value); BOOST_STATIC_ASSERT(std::is_constructible< serializer, message &>::value); BOOST_STATIC_ASSERT(! std::is_constructible< serializer, message const&>::value); struct lambda { std::size_t size; template void operator()(error_code&, ConstBufferSequence const& buffers) { size = buffer_bytes(buffers); } }; void testWriteLimit() { auto const limit = 30; lambda visit; error_code ec; response res; res.body().append(1000, '*'); serializer sr{res}; sr.limit(limit); for(;;) { sr.next(ec, visit); BEAST_EXPECT(visit.size <= limit); sr.consume(visit.size); if(sr.is_done()) break; } } void run() override { testWriteLimit(); } }; BEAST_DEFINE_TESTSUITE(beast,http,serializer); } // http } // beast } // boost