//
-// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+// 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)
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/type_traits.hpp>
#include <boost/beast/test/test_allocator.hpp>
-#include <boost/beast/unit_test/suite.hpp>
+#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <string>
namespace boost {
class fields_test : public beast::unit_test::suite
{
public:
+ static constexpr std::size_t max_static_buffer =
+ sizeof(beast::detail::temporary_buffer);
+
template<class T>
class test_allocator
{
(! res.keep_alive() && ! v));
};
- BOOST_STATIC_ASSERT(fields::max_static_buffer == 4096);
- std::string const big(4096 + 1, 'a');
+ std::string const big(max_static_buffer + 1, 'a');
// HTTP/1.0
res.version(10);
res.content_length(0);
BEAST_EXPECT(res[field::content_length] == "0");
-
+
res.content_length(100);
BEAST_EXPECT(res[field::content_length] == "100");
-
+
res.content_length(boost::none);
BEAST_EXPECT(res.count(field::content_length) == 0);
res.content_length(0);
BEAST_EXPECT(res[field::content_length] == "0");
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
-
+
res.set(field::transfer_encoding, "chunked");
res.content_length(100);
BEAST_EXPECT(res[field::content_length] == "100");
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
-
+
res.set(field::transfer_encoding, "chunked");
res.content_length(boost::none);
BEAST_EXPECT(res.count(field::content_length) == 0);
res.content_length(0);
BEAST_EXPECT(res[field::content_length] == "0");
BEAST_EXPECT(res[field::transfer_encoding] == s);
-
+
res.set(field::transfer_encoding, s);
res.content_length(100);
BEAST_EXPECT(res[field::content_length] == "100");
BEAST_EXPECT(res[field::transfer_encoding] == s);
-
+
res.set(field::transfer_encoding, s);
res.content_length(boost::none);
BEAST_EXPECT(res.count(field::content_length) == 0);
res.content_length(0);
BEAST_EXPECT(res[field::content_length] == "0");
BEAST_EXPECT(res[field::transfer_encoding] == s);
-
+
res.set(field::transfer_encoding, s + ", chunked");
res.content_length(100);
BEAST_EXPECT(res[field::content_length] == "100");
BEAST_EXPECT(res[field::transfer_encoding] == s);
-
+
res.set(field::transfer_encoding, s + ", chunked");
res.content_length(boost::none);
BEAST_EXPECT(res.count(field::content_length) == 0);
res.content_length(0);
BEAST_EXPECT(res[field::content_length] == "0");
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, " + s);
-
+
res.set(field::transfer_encoding, "chunked, " + s);
res.content_length(100);
BEAST_EXPECT(res[field::content_length] == "100");
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, " + s);
-
+
res.set(field::transfer_encoding, "chunked, " + s);
res.content_length(boost::none);
BEAST_EXPECT(res.count(field::content_length) == 0);
check("foo");
- BOOST_STATIC_ASSERT(fields::max_static_buffer == 4096);
- std::string const big(4096 + 1, 'a');
+ std::string const big(max_static_buffer + 1, 'a');
check(big);
}