forked from boostorg/beast
Boost prep
This commit is contained in:
1 parent
3777cb8b9c
commit
7139dd639a
375 files changed
+5253
-3884
No files matched your search
+13
-5
@@ -1,4 +1,11 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
add_subdirectory (core)
|
||||
add_subdirectory (http)
|
||||
@@ -13,15 +20,16 @@ if ((NOT "${VARIANT}" STREQUAL "coverage") AND
|
||||
add_subdirectory (common)
|
||||
add_subdirectory (server)
|
||||
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
|
||||
GroupSources(test "/")
|
||||
|
||||
add_executable (lib-tests
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
../extras/beast/unit_test/main.cpp
|
||||
Jamfile
|
||||
../extras/boost/beast/unit_test/main.cpp
|
||||
config.cpp
|
||||
core.cpp
|
||||
exemplars.cpp
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
import os ;
|
||||
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
|
||||
GroupSources(test/benchmarks "/")
|
||||
GroupSources(test/http "/")
|
||||
|
||||
add_executable (benchmarks
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
Jamfile
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
../http/message_fuzz.hpp
|
||||
nodejs_parser.hpp
|
||||
buffers.cpp
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
unit-test benchmarks :
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
buffers.cpp
|
||||
nodejs_parser.cpp
|
||||
parser.cpp
|
||||
utf8_checker.cpp
|
||||
#utf8_checker.cpp # causes unnecessary dependencies
|
||||
:
|
||||
<variant>coverage:<build>no
|
||||
<variant>ubasan:<build>no
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/read_size.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
@@ -18,6 +20,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class buffers_test : public beast::unit_test::suite
|
||||
@@ -233,6 +236,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(buffers,benchmarks,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(buffers,benchmarks,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ >= 7)
|
||||
#pragma GCC diagnostic push
|
||||
|
||||
@@ -4,16 +4,18 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef BEAST_HTTP_NODEJS_PARSER_HPP
|
||||
#define BEAST_HTTP_NODEJS_PARSER_HPP
|
||||
#ifndef BOOST_BEAST_HTTP_NODEJS_PARSER_HPP
|
||||
#define BOOST_BEAST_HTTP_NODEJS_PARSER_HPP
|
||||
|
||||
#include "nodejs-parser/http_parser.h"
|
||||
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/rfc7230.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/http/rfc7230.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@@ -22,6 +24,7 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -634,5 +637,6 @@ private:
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+15
-11
@@ -4,21 +4,24 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "nodejs_parser.hpp"
|
||||
#include "../http/message_fuzz.hpp"
|
||||
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/beast/core/consuming_buffers.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -53,7 +56,7 @@ public:
|
||||
{
|
||||
mg.request(v[i]);
|
||||
size_ += v[i].size();
|
||||
BEAST_EXPECT(v[i].size() > 0);
|
||||
BOOST_BEAST_EXPECT(v[i].size() > 0);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -68,7 +71,7 @@ public:
|
||||
{
|
||||
mg.response(v[i]);
|
||||
size_ += v[i].size();
|
||||
BEAST_EXPECT(v[i].size() > 0);
|
||||
BOOST_BEAST_EXPECT(v[i].size() > 0);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -113,7 +116,7 @@ public:
|
||||
Parser p;
|
||||
error_code ec;
|
||||
p.write(b.data(), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
log << to_string(b.data()) << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +132,7 @@ public:
|
||||
p.header_limit((std::numeric_limits<std::uint32_t>::max)());
|
||||
error_code ec;
|
||||
feed(b.data(), p, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
log << to_string(b.data()) << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -291,8 +294,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(parser,benchmarks,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(parser,benchmarks,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
@@ -4,13 +4,16 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <beast/websocket/detail/utf8_checker.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/websocket/detail/utf8_checker.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/locale.hpp>
|
||||
#include <chrono>
|
||||
#include <random>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class utf8_checker_test : public beast::unit_test::suite
|
||||
@@ -136,7 +139,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(utf8_checker,benchmarks,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(utf8_checker,benchmarks,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
GroupSources(example/common common)
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
GroupSources(test/common "/")
|
||||
|
||||
add_executable (common-test
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${COMMON_INCLUDES}
|
||||
Jamfile
|
||||
detect_ssl.cpp
|
||||
mime_types.cpp
|
||||
rfc7231.cpp
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
exe common-test :
|
||||
detect_ssl.cpp
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/common/detect_ssl.hpp"
|
||||
#include "example/common/detect_ssl.hpp"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/common/mime_types.hpp"
|
||||
#include "example/common/mime_types.hpp"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/common/rfc7231.hpp"
|
||||
#include "example/common/rfc7231.hpp"
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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 "example/common/session_alloc.hpp"
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#if BEAST_USE_OPENSSL
|
||||
#if BOOST_BEAST_USE_OPENSSL
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "../../example/common/ssl_stream.hpp"
|
||||
#include "example/common/ssl_stream.hpp"
|
||||
|
||||
#endif
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/common/write_msg.hpp"
|
||||
#include "example/common/write_msg.hpp"
|
||||
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/config.hpp>
|
||||
#include <boost/beast/config.hpp>
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/core.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
@@ -1,16 +1,24 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
GroupSources(example example)
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
|
||||
GroupSources(test/core "/")
|
||||
|
||||
add_executable (core-tests
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${EXAMPLE_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
Jamfile
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
buffer_test.hpp
|
||||
file_test.hpp
|
||||
async_result.cpp
|
||||
|
||||
+3
-1
@@ -4,9 +4,11 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
unit-test core-tests :
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
async_result.cpp
|
||||
bind_handler.cpp
|
||||
buffer_cat.cpp
|
||||
|
||||
@@ -4,14 +4,17 @@
|
||||
// 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 <beast/core/async_result.hpp>
|
||||
#include <boost/beast/core/async_result.hpp>
|
||||
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <cstdlib>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace {
|
||||
|
||||
@@ -36,3 +39,4 @@ static_assert(std::is_constructible<
|
||||
|
||||
} // (anon-ns)
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,12 +4,15 @@
|
||||
// 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 <beast/core/detail/base64.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
@@ -20,8 +23,8 @@ public:
|
||||
check (std::string const& in, std::string const& out)
|
||||
{
|
||||
auto const encoded = base64_encode (in);
|
||||
BEAST_EXPECT(encoded == out);
|
||||
BEAST_EXPECT(base64_decode (encoded) == in);
|
||||
BOOST_BEAST_EXPECT(encoded == out);
|
||||
BOOST_BEAST_EXPECT(base64_decode (encoded) == in);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -50,8 +53,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(base64,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(base64,core,beast);
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
@@ -4,14 +4,17 @@
|
||||
// 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 <beast/core/bind_handler.hpp>
|
||||
#include <boost/beast/core/bind_handler.hpp>
|
||||
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class bind_handler_test : public unit_test::suite
|
||||
@@ -38,7 +41,7 @@ public:
|
||||
void
|
||||
callback(int v)
|
||||
{
|
||||
BEAST_EXPECT(v == 42);
|
||||
BOOST_BEAST_EXPECT(v == 42);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -64,6 +67,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(bind_handler,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(bind_handler,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+21
-17
@@ -4,11 +4,13 @@
|
||||
// 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 <beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <iterator>
|
||||
@@ -16,6 +18,7 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class buffer_cat_test : public unit_test::suite
|
||||
@@ -99,34 +102,34 @@ public:
|
||||
std::list<const_buffer> b6;
|
||||
auto bs = buffer_cat(
|
||||
b1, b2, b3, b4, b5, b6);
|
||||
BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
BEAST_EXPECT(bsize1(bs) == 10);
|
||||
BEAST_EXPECT(bsize2(bs) == 10);
|
||||
BEAST_EXPECT(bsize3(bs) == 10);
|
||||
BEAST_EXPECT(bsize4(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(bsize1(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(bsize2(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(bsize3(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(bsize4(bs) == 10);
|
||||
std::vector<const_buffer> v;
|
||||
for(auto iter = make_reverse_iterator(bs.end());
|
||||
iter != make_reverse_iterator(bs.begin()); ++iter)
|
||||
v.emplace_back(*iter);
|
||||
BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
BOOST_BEAST_EXPECT(buffer_size(bs) == 10);
|
||||
decltype(bs) bs2(bs);
|
||||
auto bs3(std::move(bs));
|
||||
{
|
||||
boost::asio::streambuf sb1, sb2;
|
||||
BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
BOOST_BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
sb1.prepare(5), sb2.prepare(7))) == 12);
|
||||
sb1.commit(5);
|
||||
sb2.commit(7);
|
||||
BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
BOOST_BEAST_EXPECT(buffer_size(buffer_cat(
|
||||
sb1.data(), sb2.data())) == 12);
|
||||
}
|
||||
for(auto it = bs.begin(); it != bs.end(); ++it)
|
||||
{
|
||||
decltype(bs)::const_iterator copy;
|
||||
copy = it;
|
||||
BEAST_EXPECT(copy == it);
|
||||
BOOST_BEAST_EXPECT(copy == it);
|
||||
copy = copy;
|
||||
BEAST_EXPECT(copy == it);
|
||||
BOOST_BEAST_EXPECT(copy == it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +182,7 @@ public:
|
||||
std::size_t n = 0;
|
||||
for(auto it = rbegin; it != rend; ++it)
|
||||
n += buffer_size(*it);
|
||||
BEAST_EXPECT(n == 9);
|
||||
BOOST_BEAST_EXPECT(n == 9);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -205,11 +208,11 @@ public:
|
||||
pass();
|
||||
}
|
||||
auto bs2 = bs;
|
||||
BEAST_EXPECT(bs.begin() != bs2.begin());
|
||||
BEAST_EXPECT(bs.end() != bs2.end());
|
||||
BOOST_BEAST_EXPECT(bs.begin() != bs2.begin());
|
||||
BOOST_BEAST_EXPECT(bs.end() != bs2.end());
|
||||
decltype(bs)::const_iterator it;
|
||||
decltype(bs2)::const_iterator it2;
|
||||
BEAST_EXPECT(it == it2);
|
||||
BOOST_BEAST_EXPECT(it == it2);
|
||||
}
|
||||
|
||||
void run() override
|
||||
@@ -261,6 +264,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(buffer_cat,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(buffer_cat,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+27
-23
@@ -4,16 +4,19 @@
|
||||
// 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 <beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/consuming_buffers.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
@@ -109,7 +112,7 @@ public:
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
std::string s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
BOOST_BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
std::size_t z = s.size() - (x + y);
|
||||
@@ -121,14 +124,14 @@ public:
|
||||
for(std::size_t i = 0; i <= s.size() + 1; ++i)
|
||||
{
|
||||
auto pb = buffer_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb) == s.substr(0, i));
|
||||
BOOST_BEAST_EXPECT(to_string(pb) == s.substr(0, i));
|
||||
auto pb2 = pb;
|
||||
BEAST_EXPECT(to_string(pb2) == to_string(pb));
|
||||
BOOST_BEAST_EXPECT(to_string(pb2) == to_string(pb));
|
||||
pb = buffer_prefix(0, bs);
|
||||
pb2 = pb;
|
||||
BEAST_EXPECT(buffer_size(pb2) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(pb2) == 0);
|
||||
pb2 = buffer_prefix(i, bs);
|
||||
BEAST_EXPECT(to_string(pb2) == s.substr(0, i));
|
||||
BOOST_BEAST_EXPECT(to_string(pb2) == s.substr(0, i));
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -140,22 +143,22 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
using boost::asio::null_buffers;
|
||||
auto pb0 = buffer_prefix(0, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(pb0) == 0);
|
||||
auto pb1 = buffer_prefix(1, null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(pb1) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pb0, pb1) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(pb1) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_copy(pb0, pb1) == 0);
|
||||
|
||||
using pb_type = decltype(pb0);
|
||||
consuming_buffers<pb_type> cb(pb0);
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
cb.consume(1);
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_copy(cb, pb1) == 0);
|
||||
|
||||
auto pbc = buffer_prefix(2, cb);
|
||||
BEAST_EXPECT(buffer_size(pbc) == 0);
|
||||
BEAST_EXPECT(buffer_copy(pbc, cb) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(pbc) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_copy(pbc, cb) == 0);
|
||||
}
|
||||
|
||||
void testIterator()
|
||||
@@ -168,10 +171,10 @@ public:
|
||||
const_buffer{&b[1], 1},
|
||||
const_buffer{&b[2], 1}}};
|
||||
auto pb = buffer_prefix(2, bs);
|
||||
BEAST_EXPECT(bsize1(pb) == 2);
|
||||
BEAST_EXPECT(bsize2(pb) == 2);
|
||||
BEAST_EXPECT(bsize3(pb) == 2);
|
||||
BEAST_EXPECT(bsize4(pb) == 2);
|
||||
BOOST_BEAST_EXPECT(bsize1(pb) == 2);
|
||||
BOOST_BEAST_EXPECT(bsize2(pb) == 2);
|
||||
BOOST_BEAST_EXPECT(bsize3(pb) == 2);
|
||||
BOOST_BEAST_EXPECT(bsize4(pb) == 2);
|
||||
}
|
||||
|
||||
void run() override
|
||||
@@ -183,6 +186,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(buffer_prefix,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(buffer_prefix,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,19 +4,22 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef BEAST_TEST_BUFFER_TEST_HPP
|
||||
#define BEAST_TEST_BUFFER_TEST_HPP
|
||||
#ifndef BOOST_BEAST_TEST_BUFFER_TEST_HPP
|
||||
#define BOOST_BEAST_TEST_BUFFER_TEST_HPP
|
||||
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/core/read_size.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace test {
|
||||
|
||||
@@ -114,5 +117,6 @@ size_rev_post(ConstBufferSequence const& buffers)
|
||||
|
||||
} // test
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/buffered_read_stream.hpp>
|
||||
#include <boost/beast/core/buffered_read_stream.hpp>
|
||||
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/test/fail_stream.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class buffered_read_stream_test
|
||||
@@ -32,8 +35,8 @@ public:
|
||||
buffered_read_stream<socket_type, multi_buffer> srs(ios);
|
||||
buffered_read_stream<socket_type, multi_buffer> srs2(std::move(srs));
|
||||
srs = std::move(srs2);
|
||||
BEAST_EXPECT(&srs.get_io_service() == &ios);
|
||||
BEAST_EXPECT(&srs.get_io_service() == &srs2.get_io_service());
|
||||
BOOST_BEAST_EXPECT(&srs.get_io_service() == &ios);
|
||||
BOOST_BEAST_EXPECT(&srs.get_io_service() == &srs2.get_io_service());
|
||||
}
|
||||
{
|
||||
socket_type sock(ios);
|
||||
@@ -63,11 +66,11 @@ public:
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -82,11 +85,11 @@ public:
|
||||
boost::asio::read(srs, buffer(&s[0], s.size()), ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -101,11 +104,11 @@ public:
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -121,11 +124,11 @@ public:
|
||||
srs, buffer(&s[0], s.size()), do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(s == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(s == "Hello, world!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void run() override
|
||||
@@ -137,7 +140,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(buffered_read_stream,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(buffered_read_stream,core,beast);
|
||||
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
@@ -4,19 +4,22 @@
|
||||
// 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 <beast/core/buffers_adapter.hpp>
|
||||
#include <boost/beast/core/buffers_adapter.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class buffers_adapter_test : public unit_test::suite
|
||||
@@ -40,7 +43,7 @@ public:
|
||||
using boost::asio::mutable_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
BOOST_BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -57,83 +60,83 @@ public:
|
||||
mutable_buffer{&buf[i], j},
|
||||
mutable_buffer{&buf[i+j], k}}};
|
||||
buffers_adapter<decltype(bs)> ba(std::move(bs));
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf));
|
||||
BOOST_BEAST_EXPECT(ba.max_size() == sizeof(buf));
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
ba.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
BEAST_EXPECT(ba.size() == x);
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf) - x);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x);
|
||||
BOOST_BEAST_EXPECT(ba.max_size() == sizeof(buf) - x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
ba.commit(1);
|
||||
BEAST_EXPECT(ba.size() == x + y);
|
||||
BEAST_EXPECT(ba.max_size() == sizeof(buf) - (x + y));
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y);
|
||||
BOOST_BEAST_EXPECT(ba.max_size() == sizeof(buf) - (x + y));
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z); BEAST_EXPECT(buffer_size(d) == z);
|
||||
auto d = ba.prepare(z); BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
ba.commit(2);
|
||||
BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BEAST_EXPECT(ba.max_size() == 0);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BOOST_BEAST_EXPECT(ba.max_size() == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
ba.consume(t);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
ba.consume(u);
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
ba.consume(v);
|
||||
BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
ba.consume(1);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -155,9 +158,9 @@ public:
|
||||
sb_type b;
|
||||
buffers_adapter<
|
||||
sb_type::mutable_buffers_type> ba(b.prepare(3));
|
||||
BEAST_EXPECT(buffer_size(ba.prepare(3)) == 3);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.prepare(3)) == 3);
|
||||
ba.commit(2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
}
|
||||
{
|
||||
using sb_type = beast::multi_buffer;
|
||||
@@ -165,13 +168,13 @@ public:
|
||||
b.prepare(3);
|
||||
buffers_adapter<
|
||||
sb_type::mutable_buffers_type> ba(b.prepare(8));
|
||||
BEAST_EXPECT(buffer_size(ba.prepare(8)) == 8);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.prepare(8)) == 8);
|
||||
ba.commit(2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == 2);
|
||||
ba.consume(1);
|
||||
ba.commit(6);
|
||||
ba.consume(2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == 5);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == 5);
|
||||
ba.consume(5);
|
||||
}
|
||||
}
|
||||
@@ -194,6 +197,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(buffers_adapter,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(buffers_adapter,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+8
-5
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <climits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
@@ -19,7 +22,7 @@ class clamp_test : public beast::unit_test::suite
|
||||
public:
|
||||
void testClamp()
|
||||
{
|
||||
BEAST_EXPECT(clamp(
|
||||
BOOST_BEAST_EXPECT(clamp(
|
||||
(std::numeric_limits<std::uint64_t>::max)()) ==
|
||||
(std::numeric_limits<std::size_t>::max)());
|
||||
}
|
||||
@@ -30,8 +33,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(clamp,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(clamp,core,beast);
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
@@ -4,18 +4,21 @@
|
||||
// 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 <beast/core/consuming_buffers.hpp>
|
||||
#include <boost/beast/core/consuming_buffers.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class consuming_buffers_test : public beast::unit_test::suite
|
||||
@@ -44,10 +47,10 @@ public:
|
||||
void
|
||||
expect_size(std::size_t n, ConstBufferSequence const& buffers)
|
||||
{
|
||||
BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -72,9 +75,9 @@ public:
|
||||
using boost::asio::const_buffer;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
BOOST_BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
buffer_copy(buffer(buf), buffer(s));
|
||||
BEAST_EXPECT(to_string(buffer(buf)) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(buffer(buf)) == s);
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -87,24 +90,24 @@ public:
|
||||
const_buffer{&buf[i], j},
|
||||
const_buffer{&buf[i+j], k}}};
|
||||
consuming_buffers<decltype(bs)> cb(bs);
|
||||
BEAST_EXPECT(to_string(cb) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == s);
|
||||
expect_size(s.size(), cb);
|
||||
cb.consume(0);
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, 0)));
|
||||
BEAST_EXPECT(to_string(cb) == s);
|
||||
BOOST_BEAST_EXPECT(eq(cb, consumed_buffers(bs, 0)));
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == s);
|
||||
expect_size(s.size(), cb);
|
||||
cb.consume(x);
|
||||
BEAST_EXPECT(to_string(cb) == s.substr(x));
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x)));
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == s.substr(x));
|
||||
BOOST_BEAST_EXPECT(eq(cb, consumed_buffers(bs, x)));
|
||||
cb.consume(y);
|
||||
BEAST_EXPECT(to_string(cb) == s.substr(x+y));
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y)));
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == s.substr(x+y));
|
||||
BOOST_BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y)));
|
||||
cb.consume(z);
|
||||
BEAST_EXPECT(to_string(cb) == "");
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == "");
|
||||
BOOST_BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
cb.consume(1);
|
||||
BEAST_EXPECT(to_string(cb) == "");
|
||||
BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == "");
|
||||
BOOST_BEAST_EXPECT(eq(cb, consumed_buffers(bs, x+y+z)));
|
||||
}
|
||||
}}}}
|
||||
}
|
||||
@@ -123,7 +126,7 @@ public:
|
||||
};
|
||||
|
||||
consuming_buffers<test_buffer> cb;
|
||||
BEAST_EXPECT(to_string(cb) == "\r\n");
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == "\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -136,7 +139,7 @@ public:
|
||||
boost::in_place_init,
|
||||
boost::asio::const_buffers_1("\r", 1),
|
||||
boost::asio::const_buffers_1("\n", 1));
|
||||
BEAST_EXPECT(to_string(cb) == "\r\n");
|
||||
BOOST_BEAST_EXPECT(to_string(cb) == "\r\n");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -147,10 +150,10 @@ public:
|
||||
using boost::asio::null_buffers;
|
||||
consuming_buffers<null_buffers> cb(
|
||||
null_buffers{});
|
||||
BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(cb) == 0);
|
||||
consuming_buffers<null_buffers> cb2(
|
||||
null_buffers{});
|
||||
BEAST_EXPECT(buffer_copy(cb2, cb) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_copy(cb2, cb) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -162,7 +165,7 @@ public:
|
||||
std::size_t n = 0;
|
||||
for(auto it = cb.end(); it != cb.begin(); --it)
|
||||
++n;
|
||||
BEAST_EXPECT(n == 3);
|
||||
BOOST_BEAST_EXPECT(n == 3);
|
||||
}
|
||||
|
||||
void run() override
|
||||
@@ -176,6 +179,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(consuming_buffers,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(consuming_buffers,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -6,11 +6,13 @@
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/core/detail/varint.hpp>
|
||||
#include <boost/beast/core/detail/varint.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
class varint_test : public beast::unit_test::suite
|
||||
{
|
||||
@@ -18,9 +20,6 @@ public:
|
||||
void
|
||||
testVarint()
|
||||
{
|
||||
using beast::detail::varint_read;
|
||||
using beast::detail::varint_size;
|
||||
using beast::detail::varint_write;
|
||||
std::size_t n0 = 0;
|
||||
std::size_t n1 = 1;
|
||||
for(;;)
|
||||
@@ -31,7 +30,7 @@ public:
|
||||
varint_write(it, n0);
|
||||
it = &buf[0];
|
||||
auto n = varint_read(it);
|
||||
BEAST_EXPECT(n == n0);
|
||||
BOOST_BEAST_EXPECT(n == n0);
|
||||
n = n0 + n1;
|
||||
if(n < n1)
|
||||
break;
|
||||
@@ -47,6 +46,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(varint,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(varint,core,beast);
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
} // boost
|
||||
+20
-16
@@ -4,15 +4,18 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "example/common/detect_ssl.hpp"
|
||||
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/test/pipe_stream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/test/pipe_stream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -29,18 +32,18 @@ public:
|
||||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
buf[3] = 0;
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 0))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 1))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 2))));
|
||||
BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(boost::indeterminate(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 3))));
|
||||
BEAST_EXPECT(is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 4)));
|
||||
buf[0] = 0;
|
||||
BEAST_EXPECT(! is_ssl_handshake(
|
||||
BOOST_BEAST_EXPECT(! is_ssl_handshake(
|
||||
boost::asio::buffer(buf, 1)));
|
||||
}
|
||||
|
||||
@@ -54,8 +57,8 @@ public:
|
||||
error_code ec;
|
||||
flat_buffer b;
|
||||
auto const result = detect_ssl(p.server, b, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(result);
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(result);
|
||||
}
|
||||
yield_to(
|
||||
[&](yield_context yield)
|
||||
@@ -66,8 +69,8 @@ public:
|
||||
error_code ec;
|
||||
flat_buffer b;
|
||||
auto const result = async_detect_ssl(p.server, b, yield[ec]);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(result);
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(result);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,7 +82,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(doc_core_samples,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(doc_core_samples,core,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,17 +4,19 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
//[snippet_core_1a
|
||||
|
||||
#include <beast/core.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
//]
|
||||
|
||||
using namespace beast;
|
||||
using namespace boost::beast;
|
||||
|
||||
namespace doc_core_snippets {
|
||||
|
||||
@@ -23,7 +25,7 @@ void fxx()
|
||||
|
||||
//[snippet_core_1b
|
||||
//
|
||||
using namespace beast;
|
||||
using namespace boost::beast;
|
||||
|
||||
boost::asio::io_service ios;
|
||||
boost::asio::io_service::work work{ios};
|
||||
|
||||
+14
-10
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/core/drain_buffer.hpp>
|
||||
#include <boost/beast/core/drain_buffer.hpp>
|
||||
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
static_assert(is_dynamic_buffer<drain_buffer>::value,
|
||||
@@ -24,8 +27,8 @@ public:
|
||||
{
|
||||
using boost::asio::buffer_size;
|
||||
drain_buffer b;
|
||||
BEAST_EXPECT(buffer_size(b.prepare(0)) == 0);
|
||||
BEAST_EXPECT(buffer_size(b.prepare(100)) == 100);
|
||||
BOOST_BEAST_EXPECT(buffer_size(b.prepare(0)) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(b.prepare(100)) == 100);
|
||||
try
|
||||
{
|
||||
b.prepare(b.max_size() + 1);
|
||||
@@ -36,16 +39,17 @@ public:
|
||||
pass();
|
||||
}
|
||||
b.prepare(10);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
b.commit(10);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
b.consume(10);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
b.consume(1000);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(drain_buffer,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(drain_buffer,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,12 +4,15 @@
|
||||
// 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 <beast/core/detail/empty_base_optimization.hpp>
|
||||
#include <boost/beast/core/detail/empty_base_optimization.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
@@ -82,13 +85,14 @@ public:
|
||||
void
|
||||
run()
|
||||
{
|
||||
BEAST_EXPECT(test_one());
|
||||
BEAST_EXPECT(test_two());
|
||||
BOOST_BEAST_EXPECT(test_one());
|
||||
BOOST_BEAST_EXPECT(test_two());
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(empty_base_optimization,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(empty_base_optimization,core,beast);
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
} // boost
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/core/error.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/core/file.hpp>
|
||||
#include <boost/beast/core/file.hpp>
|
||||
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/file_posix.hpp>
|
||||
#include <boost/beast/core/file_posix.hpp>
|
||||
|
||||
#if BEAST_USE_POSIX_FILE
|
||||
#if BOOST_BEAST_USE_POSIX_FILE
|
||||
|
||||
#include "file_test.hpp"
|
||||
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(! std::is_copy_constructible<file_posix>::value);
|
||||
@@ -30,8 +33,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(file_posix,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(file_posix,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -4,15 +4,18 @@
|
||||
// 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 <beast/core/file_stdio.hpp>
|
||||
#include <boost/beast/core/file_stdio.hpp>
|
||||
|
||||
#include "file_test.hpp"
|
||||
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(! std::is_copy_constructible<file_stdio>::value);
|
||||
@@ -28,6 +31,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(file_stdio,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(file_stdio,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+40
-36
@@ -4,16 +4,19 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef BEAST_TEST_CORE_FILE_TEST_HPP
|
||||
#define BEAST_TEST_CORE_FILE_TEST_HPP
|
||||
#ifndef BOOST_BEAST_TEST_CORE_FILE_TEST_HPP
|
||||
#define BOOST_BEAST_TEST_CORE_FILE_TEST_HPP
|
||||
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
template<class File>
|
||||
@@ -28,95 +31,96 @@ doTestFile(beast::unit_test::suite& test)
|
||||
{
|
||||
{
|
||||
File f1;
|
||||
test.BEAST_EXPECT(! f1.is_open());
|
||||
test.BOOST_BEAST_EXPECT(! f1.is_open());
|
||||
f1.open(temp.string<std::string>().c_str(), file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
File f2{std::move(f1)};
|
||||
test.BEAST_EXPECT(! f1.is_open());
|
||||
test.BEAST_EXPECT(f2.is_open());
|
||||
test.BOOST_BEAST_EXPECT(! f1.is_open());
|
||||
test.BOOST_BEAST_EXPECT(f2.is_open());
|
||||
File f3;
|
||||
f3 = std::move(f2);
|
||||
test.BEAST_EXPECT(! f2.is_open());
|
||||
test.BEAST_EXPECT(f3.is_open());
|
||||
test.BOOST_BEAST_EXPECT(! f2.is_open());
|
||||
test.BOOST_BEAST_EXPECT(f3.is_open());
|
||||
f1.close(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
auto const temp2 = boost::filesystem::unique_path();
|
||||
f3.open(temp2.string<std::string>().c_str(), file_mode::read, ec);
|
||||
test.BEAST_EXPECT(ec);
|
||||
test.BOOST_BEAST_EXPECT(ec);
|
||||
ec.assign(0, ec.category());
|
||||
}
|
||||
boost::filesystem::remove(temp, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
}
|
||||
|
||||
File f;
|
||||
|
||||
test.BEAST_EXPECT(! f.is_open());
|
||||
test.BOOST_BEAST_EXPECT(! f.is_open());
|
||||
|
||||
f.size(ec);
|
||||
test.BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
test.BOOST_BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
ec.assign(0, ec.category());
|
||||
|
||||
f.pos(ec);
|
||||
test.BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
test.BOOST_BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
ec.assign(0, ec.category());
|
||||
|
||||
f.seek(0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
test.BOOST_BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
ec.assign(0, ec.category());
|
||||
|
||||
f.read(nullptr, 0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
test.BOOST_BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
ec.assign(0, ec.category());
|
||||
|
||||
f.write(nullptr, 0, ec);
|
||||
test.BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
test.BOOST_BEAST_EXPECT(ec == errc::invalid_argument);
|
||||
ec.assign(0, ec.category());
|
||||
|
||||
f.open(temp.string<std::string>().c_str(), file_mode::write, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
|
||||
std::string const s = "Hello, world!";
|
||||
f.write(s.data(), s.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
|
||||
auto size = f.size(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(size == s.size());
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(size == s.size());
|
||||
|
||||
auto pos = f.pos(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(pos == size);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(pos == size);
|
||||
|
||||
f.close(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
|
||||
f.open(temp.string<std::string>().c_str(), file_mode::read, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
|
||||
std::string buf;
|
||||
buf.resize(s.size());
|
||||
f.read(&buf[0], buf.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(buf == s);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(buf == s);
|
||||
|
||||
f.seek(1, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
buf.resize(3);
|
||||
f.read(&buf[0], buf.size(), ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(buf == "ell");
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(buf == "ell");
|
||||
|
||||
pos = f.pos(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BEAST_EXPECT(pos == 4);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(pos == 4);
|
||||
|
||||
f.close(ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
boost::filesystem::remove(temp, ec);
|
||||
test.BEAST_EXPECT(! ec);
|
||||
test.BOOST_BEAST_EXPECT(! ec);
|
||||
}
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/file_win32.hpp>
|
||||
#include <boost/beast/core/file_win32.hpp>
|
||||
|
||||
#if BEAST_USE_WIN32_FILE
|
||||
#if BOOST_BEAST_USE_WIN32_FILE
|
||||
|
||||
#include "file_test.hpp"
|
||||
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(! std::is_copy_constructible<file_win32>::value);
|
||||
@@ -30,8 +33,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(file_win32,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(file_win32,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+93
-89
@@ -4,20 +4,23 @@
|
||||
// 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 <beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/read_size.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/test/test_allocator.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/test/test_allocator.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
static_assert(is_dynamic_buffer<flat_buffer>::value,
|
||||
@@ -42,25 +45,25 @@ public:
|
||||
{
|
||||
{
|
||||
flat_buffer b;
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
}
|
||||
{
|
||||
flat_buffer b{500};
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BEAST_EXPECT(b.max_size() == 500);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.max_size() == 500);
|
||||
}
|
||||
{
|
||||
a_neq_t a1;
|
||||
basic_flat_buffer<a_neq_t> b{a1};
|
||||
BEAST_EXPECT(b.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b.get_allocator() == a1);
|
||||
a_neq_t a2;
|
||||
BEAST_EXPECT(b.get_allocator() != a2);
|
||||
BOOST_BEAST_EXPECT(b.get_allocator() != a2);
|
||||
}
|
||||
{
|
||||
a_neq_t a;
|
||||
basic_flat_buffer<a_neq_t> b{500, a};
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BEAST_EXPECT(b.max_size() == 500);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.max_size() == 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,34 +71,34 @@ public:
|
||||
{
|
||||
{
|
||||
basic_flat_buffer<a_t> b1{30};
|
||||
BEAST_EXPECT(b1.get_allocator()->nmove == 0);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator()->nmove == 0);
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<a_t> b2{std::move(b1)};
|
||||
BEAST_EXPECT(b2.get_allocator()->nmove == 1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator()->nmove == 1);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
{
|
||||
basic_flat_buffer<a_t> b1{30};
|
||||
ostream(b1) << "Hello";
|
||||
a_t a;
|
||||
basic_flat_buffer<a_t> b2{std::move(b1), a};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
{
|
||||
basic_flat_buffer<a_neq_t> b1{30};
|
||||
ostream(b1) << "Hello";
|
||||
a_neq_t a;
|
||||
basic_flat_buffer<a_neq_t> b2{std::move(b1), a};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,34 +107,34 @@ public:
|
||||
basic_flat_buffer<a_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<a_t> b2(b1);
|
||||
BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_flat_buffer<a_neq_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
a_neq_t a;
|
||||
basic_flat_buffer<a_neq_t> b2(b1, a);
|
||||
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_flat_buffer<a_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<a_neq_t> b2(b1);
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_flat_buffer<a_neq_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
a_t a;
|
||||
basic_flat_buffer<a_t> b2(b1, a);
|
||||
BEAST_EXPECT(b2.get_allocator() == a);
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
|
||||
// move assignment
|
||||
@@ -141,9 +144,9 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
flat_buffer b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
using na_t = test::test_allocator<char,
|
||||
@@ -152,10 +155,10 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<na_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
using na_t = test::test_allocator<char,
|
||||
@@ -164,10 +167,10 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<na_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : true
|
||||
@@ -177,8 +180,8 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<pocma_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : false
|
||||
@@ -188,8 +191,8 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<pocma_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,11 +203,11 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
flat_buffer b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
basic_flat_buffer<a_t> b3;
|
||||
b3 = b2;
|
||||
BEAST_EXPECT(to_string(b3.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b3.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : true
|
||||
@@ -214,7 +217,7 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<pocca_t> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : false
|
||||
@@ -224,7 +227,7 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<pocca_t> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,23 +235,23 @@ public:
|
||||
{
|
||||
string_view const s = "Hello, world!";
|
||||
flat_buffer b1{64};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.max_size() == 64);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
ostream(b1) << s;
|
||||
BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
{
|
||||
flat_buffer b2{b1};
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
{
|
||||
flat_buffer b2{64};
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,21 +261,21 @@ public:
|
||||
ostream(b) << "12345";
|
||||
b.consume(3);
|
||||
ostream(b) << "67890123";
|
||||
BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
}
|
||||
|
||||
// read_size
|
||||
{
|
||||
flat_buffer b{10};
|
||||
BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
b.prepare(4);
|
||||
b.commit(4);
|
||||
BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
b.consume(2);
|
||||
BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
b.prepare(8);
|
||||
b.commit(8);
|
||||
BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
}
|
||||
|
||||
// swap
|
||||
@@ -281,12 +284,12 @@ public:
|
||||
basic_flat_buffer<a_neq_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<a_neq_t> b2;
|
||||
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
using na_t = test::test_allocator<char,
|
||||
@@ -296,13 +299,13 @@ public:
|
||||
na_t a2;
|
||||
ostream(b1) << "Hello";
|
||||
basic_flat_buffer<na_t> b2{a2};
|
||||
BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +315,7 @@ public:
|
||||
b.prepare(10);
|
||||
b.commit(10);
|
||||
b.prepare(5);
|
||||
BEAST_EXPECT(b.capacity() >= 5);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 5);
|
||||
try
|
||||
{
|
||||
b.prepare(1000);
|
||||
@@ -327,15 +330,15 @@ public:
|
||||
// shrink to fit
|
||||
{
|
||||
flat_buffer b;
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
b.prepare(50);
|
||||
BEAST_EXPECT(b.capacity() == 50);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 50);
|
||||
b.commit(50);
|
||||
BEAST_EXPECT(b.capacity() == 50);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 50);
|
||||
b.prepare(75);
|
||||
BEAST_EXPECT(b.capacity() >= 125);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 125);
|
||||
b.shrink_to_fit();
|
||||
BEAST_EXPECT(b.capacity() == b.size());
|
||||
BOOST_BEAST_EXPECT(b.capacity() == b.size());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -347,6 +350,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(flat_buffer,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(flat_buffer,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
static_assert(
|
||||
@@ -33,7 +36,7 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
BOOST_BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -47,79 +50,79 @@ public:
|
||||
flat_static_buffer<sizeof(buf)> ba;
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
ba.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
BEAST_EXPECT(ba.size() == x);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
ba.commit(1);
|
||||
BEAST_EXPECT(ba.size() == x + y);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
ba.commit(2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
|
||||
BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
ba.consume(t);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
ba.consume(u);
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
ba.consume(v);
|
||||
BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
ba.consume(1);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -145,31 +148,31 @@ public:
|
||||
char buf[64];
|
||||
flat_static_buffer_base b{buf, sizeof(buf)};
|
||||
ostream(b) << s;
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
b.consume(b.size());
|
||||
BEAST_EXPECT(to_string(b.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "");
|
||||
}
|
||||
|
||||
// flat_static_buffer
|
||||
{
|
||||
flat_static_buffer<64> b1;
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.max_size() == 64);
|
||||
BEAST_EXPECT(b1.capacity() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 64);
|
||||
ostream(b1) << s;
|
||||
BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
{
|
||||
flat_static_buffer<64> b2{b1};
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
{
|
||||
flat_static_buffer<64> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +182,7 @@ public:
|
||||
write_buffer(b, "12345");
|
||||
b.consume(3);
|
||||
write_buffer(b, "67890123");
|
||||
BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
try
|
||||
{
|
||||
b.prepare(1);
|
||||
@@ -194,15 +197,15 @@ public:
|
||||
// read_size
|
||||
{
|
||||
flat_static_buffer<10> b;
|
||||
BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
b.prepare(4);
|
||||
b.commit(4);
|
||||
BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
b.consume(2);
|
||||
BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
b.prepare(8);
|
||||
b.commit(8);
|
||||
BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
}
|
||||
|
||||
// base
|
||||
@@ -210,13 +213,13 @@ public:
|
||||
flat_static_buffer<10> b;
|
||||
[&](flat_static_buffer_base& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
BOOST_BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
(b.base());
|
||||
|
||||
[&](flat_static_buffer_base const& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
BOOST_BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
(b.base());
|
||||
}
|
||||
@@ -229,6 +232,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(flat_static_buffer,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(flat_static_buffer,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,14 +4,17 @@
|
||||
// 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 <beast/core/handler_alloc.hpp>
|
||||
#include <boost/beast/core/handler_alloc.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class handler_alloc_test : public beast::unit_test::suite
|
||||
@@ -46,9 +49,9 @@ public:
|
||||
handler h2;
|
||||
handler_alloc<char, handler> a1{h};
|
||||
handler_alloc<char, handler> a2{h2};
|
||||
BEAST_EXPECT(a2 == a1);
|
||||
BOOST_BEAST_EXPECT(a2 == a1);
|
||||
auto a3 = a1;
|
||||
BEAST_EXPECT(a3 == a1);
|
||||
BOOST_BEAST_EXPECT(a3 == a1);
|
||||
{
|
||||
std::vector<char,
|
||||
handler_alloc<char, handler>> v(a1);
|
||||
@@ -58,7 +61,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(handler_alloc,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(handler_alloc,core,beast);
|
||||
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
@@ -4,14 +4,17 @@
|
||||
// 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 <beast/core/handler_ptr.hpp>
|
||||
#include <boost/beast/core/handler_ptr.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <exception>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class handler_ptr_test : public beast::unit_test::suite
|
||||
@@ -70,11 +73,11 @@ public:
|
||||
handler_ptr<T, handler> p4{std::move(h)};
|
||||
bool b = false;
|
||||
p4.invoke(std::ref(b));
|
||||
BEAST_EXPECT(b);
|
||||
BOOST_BEAST_EXPECT(b);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(handler_ptr,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(handler_ptr,core,beast);
|
||||
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+161
-157
@@ -4,23 +4,26 @@
|
||||
// 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 <beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/core/type_traits.hpp>
|
||||
#include <beast/test/test_allocator.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
#include <boost/beast/test/test_allocator.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
BOOST_STATIC_ASSERT(is_dynamic_buffer<multi_buffer>::value);
|
||||
@@ -42,10 +45,10 @@ public:
|
||||
void
|
||||
expect_size(std::size_t n, ConstBufferSequence const& buffers)
|
||||
{
|
||||
BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_pre(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_post(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_rev_pre(buffers) == n);
|
||||
BOOST_BEAST_EXPECT(test::size_rev_post(buffers) == n);
|
||||
}
|
||||
|
||||
template<class U, class V>
|
||||
@@ -62,7 +65,7 @@ public:
|
||||
using namespace test;
|
||||
using boost::asio::buffer;
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
BOOST_BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
@@ -72,28 +75,28 @@ public:
|
||||
b.commit(buffer_copy(b.prepare(x), buffer(s.data(), x)));
|
||||
b.commit(buffer_copy(b.prepare(y), buffer(s.data()+x, y)));
|
||||
b.commit(buffer_copy(b.prepare(z), buffer(s.data()+x+y, z)));
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
{
|
||||
multi_buffer mb2{b};
|
||||
BEAST_EXPECT(eq(b, mb2));
|
||||
BOOST_BEAST_EXPECT(eq(b, mb2));
|
||||
}
|
||||
{
|
||||
multi_buffer mb2;
|
||||
mb2 = b;
|
||||
BEAST_EXPECT(eq(b, mb2));
|
||||
BOOST_BEAST_EXPECT(eq(b, mb2));
|
||||
}
|
||||
{
|
||||
multi_buffer mb2{std::move(b)};
|
||||
BEAST_EXPECT(to_string(mb2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(mb2.data()) == s);
|
||||
expect_size(0, b.data());
|
||||
b = std::move(mb2);
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
expect_size(0, mb2.data());
|
||||
}
|
||||
self_assign(b, b);
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
self_assign(b, std::move(b));
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
}
|
||||
}}}
|
||||
}
|
||||
@@ -105,7 +108,7 @@ public:
|
||||
using boost::asio::buffer;
|
||||
using boost::asio::buffer_size;
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == 12);
|
||||
BOOST_BEAST_EXPECT(s.size() == 12);
|
||||
for(std::size_t i = 1; i < 12; ++i) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
for(std::size_t y = 1; y < 4; ++y) {
|
||||
@@ -117,78 +120,78 @@ public:
|
||||
multi_buffer b;
|
||||
{
|
||||
auto d = b.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
b.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
BEAST_EXPECT(b.size() == x);
|
||||
BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
BOOST_BEAST_EXPECT(b.size() == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
{
|
||||
auto d = b.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
b.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
b.commit(1);
|
||||
BEAST_EXPECT(b.size() == x + y);
|
||||
BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
BOOST_BEAST_EXPECT(b.size() == x + y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
{
|
||||
auto d = b.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = b.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
b.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
b.commit(2);
|
||||
BEAST_EXPECT(b.size() == x + y + z);
|
||||
BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(b.size() == x + y + z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(b.data()) == b.size());
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
b.consume(t);
|
||||
{
|
||||
auto d = b.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
BEAST_EXPECT(to_string(b.data()) == s.substr(t, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s.substr(t, std::string::npos));
|
||||
b.consume(u);
|
||||
BEAST_EXPECT(to_string(b.data()) == s.substr(t + u, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s.substr(t + u, std::string::npos));
|
||||
b.consume(v);
|
||||
BEAST_EXPECT(to_string(b.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "");
|
||||
b.consume(1);
|
||||
{
|
||||
auto d = b.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
}
|
||||
}}}}}
|
||||
@@ -226,18 +229,18 @@ public:
|
||||
{
|
||||
{
|
||||
multi_buffer b;
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
}
|
||||
{
|
||||
multi_buffer b{500};
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BEAST_EXPECT(b.max_size() == 500);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.max_size() == 500);
|
||||
}
|
||||
{
|
||||
unequal_t a1;
|
||||
basic_multi_buffer<unequal_t> b{a1};
|
||||
BEAST_EXPECT(b.get_allocator() == a1);
|
||||
BEAST_EXPECT(b.get_allocator() != unequal_t{});
|
||||
BOOST_BEAST_EXPECT(b.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b.get_allocator() != unequal_t{});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,14 +248,14 @@ public:
|
||||
{
|
||||
{
|
||||
basic_multi_buffer<equal_t> b1{30};
|
||||
BEAST_EXPECT(b1.get_allocator()->nmove == 0);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator()->nmove == 0);
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<equal_t> b2{std::move(b1)};
|
||||
BEAST_EXPECT(b2.get_allocator()->nmove == 1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator()->nmove == 1);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
// allocators equal
|
||||
{
|
||||
@@ -260,10 +263,10 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
equal_t a;
|
||||
basic_multi_buffer<equal_t> b2{std::move(b1), a};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
{
|
||||
// allocators unequal
|
||||
@@ -271,10 +274,10 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
unequal_t a;
|
||||
basic_multi_buffer<unequal_t> b2{std::move(b1), a};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == b2.max_size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,34 +287,34 @@ public:
|
||||
basic_multi_buffer<equal_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<equal_t> b2{b1};
|
||||
BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_multi_buffer<unequal_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
unequal_t a;
|
||||
basic_multi_buffer<unequal_t> b2(b1, a);
|
||||
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_multi_buffer<equal_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<unequal_t> b2(b1);
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
basic_multi_buffer<unequal_t> b1;
|
||||
ostream(b1) << "Hello";
|
||||
equal_t a;
|
||||
basic_multi_buffer<equal_t> b2(b1, a);
|
||||
BEAST_EXPECT(b2.get_allocator() == a);
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,9 +325,9 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
multi_buffer b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : true
|
||||
@@ -334,8 +337,8 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocma_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : false
|
||||
@@ -345,8 +348,8 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocma_t> b2;
|
||||
b2 = std::move(b1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,11 +360,11 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
multi_buffer b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
basic_multi_buffer<equal_t> b3;
|
||||
b3 = b2;
|
||||
BEAST_EXPECT(to_string(b3.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b3.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : true
|
||||
@@ -371,7 +374,7 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocca_t> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : false
|
||||
@@ -381,7 +384,7 @@ public:
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocca_t> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,60 +405,60 @@ public:
|
||||
{
|
||||
string_view const s = "Hello, world!";
|
||||
multi_buffer b1{64};
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.max_size() == 64);
|
||||
BEAST_EXPECT(b1.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 0);
|
||||
ostream(b1) << s;
|
||||
BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
{
|
||||
multi_buffer b2{b1};
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
{
|
||||
multi_buffer b2{64};
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.commit(1);
|
||||
BEAST_EXPECT(b.size() == 1);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.size() == 1);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1500);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.commit(1);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(2000);
|
||||
BEAST_EXPECT(b.capacity() >= 2000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 2000);
|
||||
b.commit(2);
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(2000);
|
||||
BEAST_EXPECT(b.capacity() >= 2000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 2000);
|
||||
b.prepare(4000);
|
||||
BEAST_EXPECT(b.capacity() >= 4000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 4000);
|
||||
b.prepare(50);
|
||||
BEAST_EXPECT(b.capacity() >= 50);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,24 +466,24 @@ public:
|
||||
{
|
||||
multi_buffer b;
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.commit(1000);
|
||||
BEAST_EXPECT(b.size() == 1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.consume(1000);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BEAST_EXPECT(b.capacity() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.capacity() == 0);
|
||||
b.prepare(1000);
|
||||
b.commit(650);
|
||||
BEAST_EXPECT(b.size() == 650);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 650);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1650);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1650);
|
||||
b.commit(100);
|
||||
BEAST_EXPECT(b.size() == 750);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 750);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 2000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 2000);
|
||||
b.commit(500);
|
||||
}
|
||||
|
||||
@@ -488,29 +491,29 @@ public:
|
||||
{
|
||||
multi_buffer b;
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.commit(1000);
|
||||
BEAST_EXPECT(b.size() == 1000);
|
||||
BEAST_EXPECT(b.capacity() >= 1000);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 1000);
|
||||
b.prepare(1000);
|
||||
BEAST_EXPECT(b.capacity() >= 2000);
|
||||
BOOST_BEAST_EXPECT(b.capacity() >= 2000);
|
||||
b.commit(750);
|
||||
BEAST_EXPECT(b.size() == 1750);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1750);
|
||||
b.consume(500);
|
||||
BEAST_EXPECT(b.size() == 1250);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1250);
|
||||
b.consume(500);
|
||||
BEAST_EXPECT(b.size() == 750);
|
||||
BOOST_BEAST_EXPECT(b.size() == 750);
|
||||
b.prepare(250);
|
||||
b.consume(750);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
b.prepare(1000);
|
||||
b.commit(800);
|
||||
BEAST_EXPECT(b.size() == 800);
|
||||
BOOST_BEAST_EXPECT(b.size() == 800);
|
||||
b.prepare(1000);
|
||||
b.commit(600);
|
||||
BEAST_EXPECT(b.size() == 1400);
|
||||
BOOST_BEAST_EXPECT(b.size() == 1400);
|
||||
b.consume(1400);
|
||||
BEAST_EXPECT(b.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b.size() == 0);
|
||||
}
|
||||
|
||||
// swap
|
||||
@@ -520,60 +523,60 @@ public:
|
||||
using pocs_t = test::test_allocator<char,
|
||||
false, true, true, true, true>;
|
||||
pocs_t a1, a2;
|
||||
BEAST_EXPECT(a1 != a2);
|
||||
BOOST_BEAST_EXPECT(a1 != a2);
|
||||
basic_multi_buffer<pocs_t> b1{a1};
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocs_t> b2{a2};
|
||||
BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator() == a2);
|
||||
BEAST_EXPECT(b2.get_allocator() == a1);
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(b2.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b2.size() == 0);
|
||||
}
|
||||
{
|
||||
// propagate_on_container_swap : false
|
||||
using pocs_t = test::test_allocator<char,
|
||||
true, true, true, false, true>;
|
||||
pocs_t a1, a2;
|
||||
BEAST_EXPECT(a1 == a2);
|
||||
BEAST_EXPECT(a1.id() != a2.id());
|
||||
BOOST_BEAST_EXPECT(a1 == a2);
|
||||
BOOST_BEAST_EXPECT(a1.id() != a2.id());
|
||||
basic_multi_buffer<pocs_t> b1{a1};
|
||||
ostream(b1) << "Hello";
|
||||
basic_multi_buffer<pocs_t> b2{a2};
|
||||
BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator() == a2);
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator().id() == a1.id());
|
||||
BEAST_EXPECT(b2.get_allocator().id() == a2.id());
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator().id() == a1.id());
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator().id() == a2.id());
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == "Hello");
|
||||
swap(b1, b2);
|
||||
BEAST_EXPECT(b1.get_allocator().id() == a1.id());
|
||||
BEAST_EXPECT(b2.get_allocator().id() == a2.id());
|
||||
BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BEAST_EXPECT(b2.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.get_allocator().id() == a1.id());
|
||||
BOOST_BEAST_EXPECT(b2.get_allocator().id() == a2.id());
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == "Hello");
|
||||
BOOST_BEAST_EXPECT(b2.size() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
// read_size
|
||||
{
|
||||
multi_buffer b{10};
|
||||
BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
b.prepare(4);
|
||||
b.commit(4);
|
||||
BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
b.consume(2);
|
||||
BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
b.prepare(8);
|
||||
b.commit(8);
|
||||
BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -587,6 +590,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(multi_buffer,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(multi_buffer,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+10
-6
@@ -4,15 +4,18 @@
|
||||
// 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 <beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class ostream_test : public beast::unit_test::suite
|
||||
@@ -26,7 +29,7 @@ public:
|
||||
auto os = ostream(b);
|
||||
os << "Hello, world!\n";
|
||||
os.flush();
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
buffers(b.data())) == "Hello, world!\n");
|
||||
auto os2 = std::move(os);
|
||||
}
|
||||
@@ -42,12 +45,13 @@ public:
|
||||
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef";
|
||||
multi_buffer b;
|
||||
ostream(b) << s;
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
buffers(b.data())) == s);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(ostream,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(ostream,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/core/prepare_buffers.hpp>
|
||||
|
||||
+10
-6
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
|
||||
#include <beast/core/drain_buffer.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/drain_buffer.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class read_size_test : public beast::unit_test::suite
|
||||
@@ -39,6 +42,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(read_size,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(read_size,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+8
-5
@@ -4,11 +4,14 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <beast/core/detail/sha1.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/detail/sha1.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
@@ -54,7 +57,7 @@ public:
|
||||
init(ctx);
|
||||
update(ctx, message.data(), message.size());
|
||||
finish(ctx, &result[0]);
|
||||
BEAST_EXPECT(result == digest);
|
||||
BOOST_BEAST_EXPECT(result == digest);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -73,8 +76,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(sha1,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(sha1,core,beast);
|
||||
|
||||
} // test
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+9
-5
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/core/span.hpp>
|
||||
#include <boost/beast/core/span.hpp>
|
||||
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class span_test : public beast::unit_test::suite
|
||||
@@ -39,7 +42,7 @@ public:
|
||||
testSpan()
|
||||
{
|
||||
span<char const> sp{"hello", 5};
|
||||
BEAST_EXPECT(sp.size() == 5);
|
||||
BOOST_BEAST_EXPECT(sp.size() == 5);
|
||||
std::string s("world");
|
||||
sp = s;
|
||||
}
|
||||
@@ -51,6 +54,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(span,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(span,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+52
-48
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/core/static_buffer.hpp>
|
||||
#include <boost/beast/core/static_buffer.hpp>
|
||||
|
||||
#include "buffer_test.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/string.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
static_assert(
|
||||
@@ -33,7 +36,7 @@ public:
|
||||
using boost::asio::buffer_size;
|
||||
char buf[12];
|
||||
std::string const s = "Hello, world";
|
||||
BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
BOOST_BEAST_EXPECT(s.size() == sizeof(buf));
|
||||
for(std::size_t i = 1; i < 4; ++i) {
|
||||
for(std::size_t j = 1; j < 4; ++j) {
|
||||
for(std::size_t x = 1; x < 4; ++x) {
|
||||
@@ -47,79 +50,79 @@ public:
|
||||
static_buffer<sizeof(buf)> ba;
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
ba.commit(buffer_copy(d, buffer(s.data(), x)));
|
||||
}
|
||||
BEAST_EXPECT(ba.size() == x);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x, y)));
|
||||
}
|
||||
ba.commit(1);
|
||||
BEAST_EXPECT(ba.size() == x + y);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
{
|
||||
auto d = ba.prepare(x);
|
||||
BEAST_EXPECT(buffer_size(d) == x);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == x);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(y);
|
||||
BEAST_EXPECT(buffer_size(d) == y);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == y);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
{
|
||||
auto d = ba.prepare(z);
|
||||
BEAST_EXPECT(buffer_size(d) == z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == z);
|
||||
ba.commit(buffer_copy(d, buffer(s.data()+x+y, z)));
|
||||
}
|
||||
ba.commit(2);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
|
||||
BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == buffer_size(ba.mutable_data()));
|
||||
BOOST_BEAST_EXPECT(ba.size() == x + y + z);
|
||||
BOOST_BEAST_EXPECT(buffer_size(ba.data()) == ba.size());
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s);
|
||||
ba.consume(t);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t, std::string::npos));
|
||||
ba.consume(u);
|
||||
BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == s.substr(t + u, std::string::npos));
|
||||
ba.consume(v);
|
||||
BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(ba.data()) == "");
|
||||
ba.consume(1);
|
||||
{
|
||||
auto d = ba.prepare(0);
|
||||
BEAST_EXPECT(buffer_size(d) == 0);
|
||||
BOOST_BEAST_EXPECT(buffer_size(d) == 0);
|
||||
}
|
||||
try
|
||||
{
|
||||
@@ -145,31 +148,31 @@ public:
|
||||
char buf[64];
|
||||
static_buffer_base b{buf, sizeof(buf)};
|
||||
ostream(b) << s;
|
||||
BEAST_EXPECT(to_string(b.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == s);
|
||||
b.consume(b.size());
|
||||
BEAST_EXPECT(to_string(b.data()) == "");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "");
|
||||
}
|
||||
|
||||
// static_buffer
|
||||
{
|
||||
static_buffer<64> b1;
|
||||
BEAST_EXPECT(b1.size() == 0);
|
||||
BEAST_EXPECT(b1.max_size() == 64);
|
||||
BEAST_EXPECT(b1.capacity() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.size() == 0);
|
||||
BOOST_BEAST_EXPECT(b1.max_size() == 64);
|
||||
BOOST_BEAST_EXPECT(b1.capacity() == 64);
|
||||
ostream(b1) << s;
|
||||
BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b1.data()) == s);
|
||||
{
|
||||
static_buffer<64> b2{b1};
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
{
|
||||
static_buffer<64> b2;
|
||||
b2 = b1;
|
||||
BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s);
|
||||
b2.consume(7);
|
||||
BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
BOOST_BEAST_EXPECT(to_string(b2.data()) == s.substr(7));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +182,7 @@ public:
|
||||
write_buffer(b, "12345");
|
||||
b.consume(3);
|
||||
write_buffer(b, "67890123");
|
||||
BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
BOOST_BEAST_EXPECT(to_string(b.data()) == "4567890123");
|
||||
try
|
||||
{
|
||||
b.prepare(1);
|
||||
@@ -194,15 +197,15 @@ public:
|
||||
// read_size
|
||||
{
|
||||
static_buffer<10> b;
|
||||
BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 10);
|
||||
b.prepare(4);
|
||||
b.commit(4);
|
||||
BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 6);
|
||||
b.consume(2);
|
||||
BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 8);
|
||||
b.prepare(8);
|
||||
b.commit(8);
|
||||
BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
BOOST_BEAST_EXPECT(read_size(b, 512) == 0);
|
||||
}
|
||||
|
||||
// base
|
||||
@@ -210,13 +213,13 @@ public:
|
||||
static_buffer<10> b;
|
||||
[&](static_buffer_base& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
BOOST_BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
(b.base());
|
||||
|
||||
[&](static_buffer_base const& base)
|
||||
{
|
||||
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
BOOST_BEAST_EXPECT(base.max_size() == b.capacity());
|
||||
}
|
||||
(b.base());
|
||||
}
|
||||
@@ -229,6 +232,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(static_buffer,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(static_buffer,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+353
-349
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/core/string.hpp>
|
||||
#include <boost/beast/core/string.hpp>
|
||||
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/core/string_param.hpp>
|
||||
#include <boost/beast/core/string_param.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <beast/core/detail/type_traits.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/detail/type_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
class string_param_test : public unit_test::suite
|
||||
@@ -21,7 +24,7 @@ public:
|
||||
void
|
||||
check(string_param const& v, string_view s)
|
||||
{
|
||||
BEAST_EXPECT(static_cast<string_view>(v) == s);
|
||||
BOOST_BEAST_EXPECT(static_cast<string_view>(v) == s);
|
||||
}
|
||||
|
||||
class repeater
|
||||
@@ -74,6 +77,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(string_param,core,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(string_param,core,beast);
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,15 +4,18 @@
|
||||
// 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 <beast/core/type_traits.hpp>
|
||||
#include <boost/beast/core/type_traits.hpp>
|
||||
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
#include <boost/asio/detail/consuming_buffers.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
|
||||
namespace detail {
|
||||
@@ -160,3 +163,4 @@ BOOST_STATIC_ASSERT(! is_sync_write_stream<not_a_stream>::value);
|
||||
} // (anonymous)
|
||||
|
||||
} // beast
|
||||
} // boost
|
||||
+4
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/detail/zlib/deflate_stream.hpp>
|
||||
@@ -15,6 +17,7 @@
|
||||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace zlib {
|
||||
|
||||
@@ -229,4 +232,4 @@ BEAST_DEFINE_TESTSUITE(zlib,core,beast);
|
||||
|
||||
} // zlib
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+8
-4
@@ -4,15 +4,18 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/file_base.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/type_traits.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/file_base.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/http/type_traits.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -343,3 +346,4 @@ struct File
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/http.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
@@ -1,18 +1,26 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
GroupSources(example example)
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
|
||||
GroupSources(test/http "/")
|
||||
|
||||
add_executable (http-tests
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${EXAMPLE_INCLUDES}
|
||||
${EXTRAS_INCLUDES}
|
||||
Jamfile
|
||||
message_fuzz.hpp
|
||||
test_parser.hpp
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
basic_dynamic_body.cpp
|
||||
basic_file_body.cpp
|
||||
basic_parser.cpp
|
||||
|
||||
+3
-1
@@ -4,9 +4,11 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
unit-test http-tests :
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
basic_dynamic_body.cpp
|
||||
basic_file_body.cpp
|
||||
basic_parser.cpp
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/http/basic_dynamic_body.hpp>
|
||||
#include <boost/beast/http/basic_dynamic_body.hpp>
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/http/basic_file_body.hpp>
|
||||
#include <boost/beast/http/basic_file_body.hpp>
|
||||
+104
-100
@@ -4,23 +4,26 @@
|
||||
// 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 <beast/http/basic_parser.hpp>
|
||||
#include <boost/beast/http/basic_parser.hpp>
|
||||
|
||||
#include "message_fuzz.hpp"
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <beast/core/buffer_cat.hpp>
|
||||
#include <beast/core/buffer_prefix.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/test/fuzz.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/buffer_cat.hpp>
|
||||
#include <boost/beast/core/buffer_prefix.hpp>
|
||||
#include <boost/beast/core/consuming_buffers.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/test/fuzz.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -52,7 +55,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.BEAST_EXPECT(p.version == version_);
|
||||
s_.BOOST_BEAST_EXPECT(p.version == version_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -72,7 +75,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.BEAST_EXPECT(p.status == status_);
|
||||
s_.BOOST_BEAST_EXPECT(p.status == status_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,13 +96,13 @@ public:
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
if(flags_ & parse_flag::chunked)
|
||||
s_.BEAST_EXPECT(p.is_chunked());
|
||||
s_.BOOST_BEAST_EXPECT(p.is_chunked());
|
||||
if(flags_ & parse_flag::connection_keep_alive)
|
||||
s_.BEAST_EXPECT(p.is_keep_alive());
|
||||
s_.BOOST_BEAST_EXPECT(p.is_keep_alive());
|
||||
if(flags_ & parse_flag::connection_close)
|
||||
s_.BEAST_EXPECT(! p.is_keep_alive());
|
||||
s_.BOOST_BEAST_EXPECT(! p.is_keep_alive());
|
||||
if(flags_ & parse_flag::upgrade)
|
||||
s_.BEAST_EXPECT(! p.is_upgrade());
|
||||
s_.BOOST_BEAST_EXPECT(! p.is_upgrade());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +122,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.BEAST_EXPECT(p.is_keep_alive() == v_);
|
||||
s_.BOOST_BEAST_EXPECT(p.is_keep_alive() == v_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -141,7 +144,7 @@ public:
|
||||
void
|
||||
operator()(Parser const& p) const
|
||||
{
|
||||
s_.BEAST_EXPECT(p.body == body_);
|
||||
s_.BOOST_BEAST_EXPECT(p.body == body_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,24 +165,24 @@ public:
|
||||
error_code ec;
|
||||
consuming_buffers<ConstBufferSequence> cb{buffers};
|
||||
auto n = p.put(buffer_prefix(i, cb), ec);
|
||||
if(! BEAST_EXPECTS(! ec ||
|
||||
if(! BOOST_BEAST_EXPECTS(! ec ||
|
||||
ec == error::need_more, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(! p.is_done()))
|
||||
if(! BOOST_BEAST_EXPECT(! p.is_done()))
|
||||
continue;
|
||||
cb.consume(n);
|
||||
n = p.put(cb, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(n == boost::asio::buffer_size(cb)))
|
||||
if(! BOOST_BEAST_EXPECT(n == boost::asio::buffer_size(cb)))
|
||||
continue;
|
||||
if(p.need_eof())
|
||||
{
|
||||
p.put_eof(ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
}
|
||||
if(! BEAST_EXPECT(p.is_done()))
|
||||
if(! BOOST_BEAST_EXPECT(p.is_done()))
|
||||
continue;
|
||||
test(p);
|
||||
}
|
||||
@@ -192,14 +195,14 @@ public:
|
||||
cb.consume(i);
|
||||
auto n = p.put(buffer_cat(
|
||||
buffer_prefix(i, buffers), cb), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(n == size))
|
||||
if(! BOOST_BEAST_EXPECT(n == size))
|
||||
continue;
|
||||
if(p.need_eof())
|
||||
{
|
||||
p.put_eof(ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
}
|
||||
test(p);
|
||||
@@ -246,16 +249,16 @@ public:
|
||||
pass();
|
||||
continue;
|
||||
}
|
||||
if(! BEAST_EXPECTS(
|
||||
if(! BOOST_BEAST_EXPECTS(
|
||||
ec == error::need_more, ec.message()))
|
||||
continue;
|
||||
if(! BEAST_EXPECT(! p.is_done()))
|
||||
if(! BOOST_BEAST_EXPECT(! p.is_done()))
|
||||
continue;
|
||||
cb.consume(n);
|
||||
n = p.put(cb, ec);
|
||||
if(! ec)
|
||||
p.put_eof(ec);
|
||||
BEAST_EXPECTS(ec == result, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == result, ec.message());
|
||||
}
|
||||
for(std::size_t i = 1; i < msg.size() - 1; ++i)
|
||||
{
|
||||
@@ -268,7 +271,7 @@ public:
|
||||
msg.data() + i, msg.size() - i}), ec);
|
||||
if(! ec)
|
||||
p.put_eof(ec);
|
||||
BEAST_EXPECTS(ec == result, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == result, ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +328,7 @@ public:
|
||||
parsegrind<parser<true, string_body>>(m,
|
||||
[&](parser<true, string_body> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.get()["f"] == value);
|
||||
BOOST_BEAST_EXPECT(p.get()["f"] == value);
|
||||
});
|
||||
};
|
||||
check("x", "x");
|
||||
@@ -366,12 +369,12 @@ public:
|
||||
"*",
|
||||
[&](test_parser<true> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BEAST_EXPECT(p.got_on_field == 2);
|
||||
BEAST_EXPECT(p.got_on_header == 1);
|
||||
BEAST_EXPECT(p.got_on_body == 1);
|
||||
BEAST_EXPECT(p.got_on_chunk == 0);
|
||||
BEAST_EXPECT(p.got_on_complete == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_field == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_header == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_body == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_chunk == 0);
|
||||
BOOST_BEAST_EXPECT(p.got_on_complete == 1);
|
||||
});
|
||||
parsegrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -381,12 +384,12 @@ public:
|
||||
"*",
|
||||
[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BEAST_EXPECT(p.got_on_field == 2);
|
||||
BEAST_EXPECT(p.got_on_header == 1);
|
||||
BEAST_EXPECT(p.got_on_body == 1);
|
||||
BEAST_EXPECT(p.got_on_chunk == 0);
|
||||
BEAST_EXPECT(p.got_on_complete == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_field == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_header == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_body == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_chunk == 0);
|
||||
BOOST_BEAST_EXPECT(p.got_on_complete == 1);
|
||||
});
|
||||
parsegrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -397,12 +400,12 @@ public:
|
||||
"0\r\n\r\n",
|
||||
[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BEAST_EXPECT(p.got_on_field == 2);
|
||||
BEAST_EXPECT(p.got_on_header == 1);
|
||||
BEAST_EXPECT(p.got_on_body == 1);
|
||||
BEAST_EXPECT(p.got_on_chunk == 2);
|
||||
BEAST_EXPECT(p.got_on_complete == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_field == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_header == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_body == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_chunk == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_complete == 1);
|
||||
});
|
||||
parsegrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -413,12 +416,12 @@ public:
|
||||
"0\r\n\r\n",
|
||||
[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BEAST_EXPECT(p.got_on_field == 2);
|
||||
BEAST_EXPECT(p.got_on_header == 1);
|
||||
BEAST_EXPECT(p.got_on_body == 1);
|
||||
BEAST_EXPECT(p.got_on_chunk == 2);
|
||||
BEAST_EXPECT(p.got_on_complete == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_begin == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_field == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_header == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_body == 1);
|
||||
BOOST_BEAST_EXPECT(p.got_on_chunk == 2);
|
||||
BOOST_BEAST_EXPECT(p.got_on_complete == 1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -670,8 +673,8 @@ public:
|
||||
parsegrind<P>(c(s),
|
||||
[&](P const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.content_length());
|
||||
BEAST_EXPECT(p.content_length() && *p.content_length() == v);
|
||||
BOOST_BEAST_EXPECT(p.content_length());
|
||||
BOOST_BEAST_EXPECT(p.content_length() && *p.content_length() == v);
|
||||
}, true);
|
||||
};
|
||||
|
||||
@@ -781,7 +784,7 @@ public:
|
||||
"\r\n",
|
||||
[&](P const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.is_upgrade());
|
||||
BOOST_BEAST_EXPECT(p.is_upgrade());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -805,17 +808,17 @@ public:
|
||||
"\r\n",
|
||||
[&](test_parser<true> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.fields.size() == 10);
|
||||
BEAST_EXPECT(p.fields.at("a") == "0");
|
||||
BEAST_EXPECT(p.fields.at("b") == "1");
|
||||
BEAST_EXPECT(p.fields.at("c") == "2");
|
||||
BEAST_EXPECT(p.fields.at("d") == "3");
|
||||
BEAST_EXPECT(p.fields.at("e") == "4");
|
||||
BEAST_EXPECT(p.fields.at("f") == "5");
|
||||
BEAST_EXPECT(p.fields.at("g") == "6");
|
||||
BEAST_EXPECT(p.fields.at("h") == "7");
|
||||
BEAST_EXPECT(p.fields.at("i") == "8");
|
||||
BEAST_EXPECT(p.fields.at("j") == "9");
|
||||
BOOST_BEAST_EXPECT(p.fields.size() == 10);
|
||||
BOOST_BEAST_EXPECT(p.fields.at("a") == "0");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("b") == "1");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("c") == "2");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("d") == "3");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("e") == "4");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("f") == "5");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("g") == "6");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("h") == "7");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("i") == "8");
|
||||
BOOST_BEAST_EXPECT(p.fields.at("j") == "9");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -834,7 +837,7 @@ public:
|
||||
p.header_limit(10);
|
||||
p.eager(true);
|
||||
p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(ec == error::header_limit, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::header_limit, ec.message());
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
@@ -848,7 +851,7 @@ public:
|
||||
p.body_limit(1);
|
||||
p.eager(true);
|
||||
p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
@@ -861,7 +864,7 @@ public:
|
||||
p.body_limit(1);
|
||||
p.eager(true);
|
||||
p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
@@ -877,7 +880,7 @@ public:
|
||||
p.body_limit(1);
|
||||
p.eager(true);
|
||||
p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::body_limit, ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,7 +914,7 @@ public:
|
||||
"0\r\n\r\n"
|
||||
,[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "abcd");
|
||||
BOOST_BEAST_EXPECT(p.body == "abcd");
|
||||
});
|
||||
parsegrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -929,7 +932,7 @@ public:
|
||||
"\r\n"
|
||||
,[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "*****--");
|
||||
BOOST_BEAST_EXPECT(p.body == "*****--");
|
||||
});
|
||||
|
||||
parsegrind<test_parser<true>>(
|
||||
@@ -962,8 +965,8 @@ public:
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
{
|
||||
error_code ec;
|
||||
@@ -972,8 +975,8 @@ public:
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
// response without Content-Length or
|
||||
@@ -985,9 +988,9 @@ public:
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(! p.is_done());
|
||||
BEAST_EXPECT(p.need_eof());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(! p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.need_eof());
|
||||
}
|
||||
|
||||
// 304 "Not Modified" response does not require eof
|
||||
@@ -998,8 +1001,8 @@ public:
|
||||
"HTTP/1.0 304 Not Modified\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
// Chunked response does not require eof
|
||||
@@ -1011,13 +1014,13 @@ public:
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(! p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(! p.is_done());
|
||||
feed(buf(
|
||||
"0\r\n\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
// restart: 1.0 assumes Connection: close
|
||||
@@ -1028,8 +1031,8 @@ public:
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
// restart: 1.1 assumes Connection: keep-alive
|
||||
@@ -1040,8 +1043,8 @@ public:
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n"
|
||||
), p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
failgrind<test_parser<true>>(
|
||||
@@ -1079,9 +1082,9 @@ public:
|
||||
"die!";
|
||||
p.put(boost::asio::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
|
||||
// https://github.com/vinniefalco/Beast/issues/496
|
||||
@@ -1099,7 +1102,7 @@ public:
|
||||
"0\r\n\r\n"
|
||||
,[&](P const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "abcd");
|
||||
BOOST_BEAST_EXPECT(p.body == "abcd");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1137,7 +1140,7 @@ public:
|
||||
p.eager(true);
|
||||
p.put(boost::asio::const_buffers_1{
|
||||
msg.data(), msg.size()}, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
grind(msg);
|
||||
};
|
||||
auto const bad =
|
||||
@@ -1154,7 +1157,7 @@ public:
|
||||
p.eager(true);
|
||||
p.put(boost::asio::const_buffers_1{
|
||||
msg.data(), msg.size()}, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
BOOST_BEAST_EXPECT(ec);
|
||||
grind(msg);
|
||||
};
|
||||
chunkExtensionsTest(good, bad);
|
||||
@@ -1189,7 +1192,7 @@ public:
|
||||
error_code ec;
|
||||
test_parser<true> p;
|
||||
feed(boost::asio::buffer(buf, sizeof(buf)), p, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
BOOST_BEAST_EXPECT(ec);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -1218,7 +1221,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(basic_parser,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(basic_parser,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,6 +4,8 @@
|
||||
// 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 <beast/http/buffer_body.hpp>
|
||||
#include <boost/beast/http/buffer_body.hpp>
|
||||
+30
-27
@@ -4,19 +4,22 @@
|
||||
// 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 <beast/http/chunk_encode.hpp>
|
||||
#include <boost/beast/http/chunk_encode.hpp>
|
||||
|
||||
#include "message_fuzz.hpp"
|
||||
|
||||
#include <beast/core/static_string.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/test/fuzz.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/static_string.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/test/fuzz.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <random>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -51,11 +54,11 @@ public:
|
||||
check(string_view match, Args&&... args)
|
||||
{
|
||||
T t{std::forward<Args>(args)...};
|
||||
BEAST_EXPECT(to_string(t) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t) == match);
|
||||
T t2{t};
|
||||
BEAST_EXPECT(to_string(t2) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t2) == match);
|
||||
T t3{std::move(t2)};
|
||||
BEAST_EXPECT(to_string(t3) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t3) == match);
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
@@ -63,11 +66,11 @@ public:
|
||||
check_fwd(string_view match, Args&&... args)
|
||||
{
|
||||
T t{std::forward<Args>(args)...};
|
||||
BEAST_EXPECT(to_string(t) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t) == match);
|
||||
T t2{t};
|
||||
BEAST_EXPECT(to_string(t2) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t2) == match);
|
||||
T t3{std::move(t2)};
|
||||
BEAST_EXPECT(to_string(t3) == match);
|
||||
BOOST_BEAST_EXPECT(to_string(t3) == match);
|
||||
}
|
||||
|
||||
using cb_t = boost::asio::const_buffers_1;
|
||||
@@ -217,20 +220,20 @@ public:
|
||||
};
|
||||
chunk_extensions ce;
|
||||
ce.insert("x");
|
||||
BEAST_EXPECT(ce.str() == ";x");
|
||||
BEAST_EXPECT(str(ce) == "x,");
|
||||
BOOST_BEAST_EXPECT(ce.str() == ";x");
|
||||
BOOST_BEAST_EXPECT(str(ce) == "x,");
|
||||
ce.insert("y", "z");
|
||||
BEAST_EXPECT(ce.str() == ";x;y=z");
|
||||
BEAST_EXPECT(str(ce) == "x,y,z,");
|
||||
BOOST_BEAST_EXPECT(ce.str() == ";x;y=z");
|
||||
BOOST_BEAST_EXPECT(str(ce) == "x,y,z,");
|
||||
ce.insert("z", R"(")");
|
||||
BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"")");
|
||||
BEAST_EXPECT(str(ce) == R"(x,y,z,z,",)");
|
||||
BOOST_BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"")");
|
||||
BOOST_BEAST_EXPECT(str(ce) == R"(x,y,z,z,",)");
|
||||
ce.insert("p", R"(\)");
|
||||
BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\")");
|
||||
BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,)");
|
||||
BOOST_BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\")");
|
||||
BOOST_BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,)");
|
||||
ce.insert("q", R"(1"2\)");
|
||||
BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\";q="1\"2\\")");
|
||||
BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,q,1"2\,)");
|
||||
BOOST_BEAST_EXPECT(ce.str() == R"(;x;y=z;z="\"";p="\\";q="1\"2\\")");
|
||||
BOOST_BEAST_EXPECT(str(ce) == R"(x,y,z,z,",p,\,q,1"2\,)");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -256,7 +259,7 @@ public:
|
||||
}
|
||||
chunk_extensions c2;
|
||||
c2.parse(c1.str(), ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
chunk_extensions c3;
|
||||
for(auto const& v : c2)
|
||||
@@ -264,7 +267,7 @@ public:
|
||||
c3.insert(v.first);
|
||||
else
|
||||
c3.insert(v.first, v.second);
|
||||
BEAST_EXPECTS(c2.str() == c3.str(), c3.str());
|
||||
BOOST_BEAST_EXPECTS(c2.str() == c3.str(), c3.str());
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -274,7 +277,7 @@ public:
|
||||
error_code ec;
|
||||
chunk_extensions ce;
|
||||
ce.parse(s, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
grind(s);
|
||||
};
|
||||
auto const bad =
|
||||
@@ -283,7 +286,7 @@ public:
|
||||
error_code ec;
|
||||
chunk_extensions ce;
|
||||
ce.parse(s, ec);
|
||||
BEAST_EXPECT(ec);
|
||||
BOOST_BEAST_EXPECT(ec);
|
||||
grind(s);
|
||||
};
|
||||
chunkExtensionsTest(good, bad);
|
||||
@@ -301,8 +304,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(chunk_encode,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(chunk_encode,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+39
-35
@@ -4,28 +4,31 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "example/doc/http_examples.hpp"
|
||||
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/read_size.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/detail/clamp.hpp>
|
||||
#include <beast/http/chunk_encode.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/test/pipe_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/string_ostream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/read_size.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/detail/clamp.hpp>
|
||||
#include <boost/beast/http/chunk_encode.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/test/pipe_stream.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/string_ostream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <sstream>
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -71,7 +74,7 @@ public:
|
||||
flat_buffer buffer;
|
||||
receive_expect_100_continue(
|
||||
p.server, buffer, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
},
|
||||
[&](yield_context)
|
||||
{
|
||||
@@ -87,7 +90,7 @@ public:
|
||||
error_code ec;
|
||||
send_expect_100_continue(
|
||||
p.client, buffer, req, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -102,8 +105,8 @@ public:
|
||||
test::pipe p{ios_};
|
||||
error_code ec;
|
||||
send_cgi_response(child.server, p.client, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(equal_body<false>(p.server.str(), s));
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(p.server.str(), s));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -124,7 +127,7 @@ public:
|
||||
|
||||
error_code ec;
|
||||
write(downstream.client, req);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
downstream.client.close();
|
||||
|
||||
flat_buffer buffer;
|
||||
@@ -135,8 +138,8 @@ public:
|
||||
h.erase("Content-Length");
|
||||
h.set("Transfer-Encoding", "chunked");
|
||||
});
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(equal_body<true>(
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(equal_body<true>(
|
||||
upstream.server.str(), req.body));
|
||||
}
|
||||
|
||||
@@ -153,8 +156,8 @@ public:
|
||||
flat_buffer buffer;
|
||||
response<string_body> res;
|
||||
read_istream(is, buffer, res, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(boost::lexical_cast<
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<
|
||||
std::string>(res) == s);
|
||||
}
|
||||
|
||||
@@ -169,8 +172,8 @@ public:
|
||||
req.insert(field::user_agent, "test");
|
||||
error_code ec;
|
||||
write_ostream(os, req, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(boost::lexical_cast<
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<
|
||||
std::string>(req) == os.str());
|
||||
}
|
||||
|
||||
@@ -189,7 +192,7 @@ public:
|
||||
custom_parser<true> p;
|
||||
p.put(boost::asio::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
{
|
||||
string_view s{
|
||||
@@ -206,7 +209,7 @@ public:
|
||||
custom_parser<false> p;
|
||||
p.put(boost::asio::buffer(
|
||||
s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,14 +223,14 @@ public:
|
||||
error_code ec;
|
||||
flat_buffer buffer;
|
||||
do_server_head(p.server, buffer, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
},
|
||||
[&](yield_context)
|
||||
{
|
||||
error_code ec;
|
||||
flat_buffer buffer;
|
||||
auto res = do_head_request(p.client, buffer, "/", ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -263,7 +266,7 @@ public:
|
||||
handler h;
|
||||
flat_buffer buffer;
|
||||
do_form_request(p.server, buffer, h);
|
||||
BEAST_EXPECT(h.body == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(h.body == "Hello, world!");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -283,8 +286,8 @@ public:
|
||||
flat_buffer b;
|
||||
std::stringstream ss;
|
||||
read_and_print_body<false>(ss, c.server, b, ec);
|
||||
if(BEAST_EXPECTS(! ec, ec.message()))
|
||||
BEAST_EXPECT(ss.str() == s);
|
||||
if(BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
BOOST_BEAST_EXPECT(ss.str() == s);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -339,7 +342,7 @@ public:
|
||||
trailers,
|
||||
std::allocator<double>{}
|
||||
), ec);
|
||||
BEAST_EXPECT(
|
||||
BOOST_BEAST_EXPECT(
|
||||
boost::lexical_cast<std::string>(
|
||||
buffers(p.server.buffer.data())) ==
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -391,8 +394,8 @@ public:
|
||||
flat_buffer b;
|
||||
std::stringstream ss;
|
||||
print_chunked_body<false>(ss, c.client, b, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(ss.str() ==
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(ss.str() ==
|
||||
"Chunk Body: First\n"
|
||||
"Extension: quality = 1.0\n"
|
||||
"Chunk Body: Hello, world!\n"
|
||||
@@ -425,7 +428,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(doc_examples,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(doc_examples,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,19 +4,21 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <beast/core.hpp>
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
using namespace beast;
|
||||
using namespace boost::beast;
|
||||
|
||||
//[http_snippet_1
|
||||
|
||||
#include <beast/http.hpp>
|
||||
using namespace beast::http;
|
||||
#include <boost/beast/http.hpp>
|
||||
using namespace boost::beast::http;
|
||||
|
||||
//]
|
||||
|
||||
|
||||
+15
-11
@@ -4,19 +4,22 @@
|
||||
// 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 <beast/http/dynamic_body.hpp>
|
||||
#include <boost/beast/http/dynamic_body.hpp>
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -39,13 +42,14 @@ public:
|
||||
multi_buffer b;
|
||||
read(ss, b, p);
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
buffers(m.body.data())) == "xyz");
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(m) == s);
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(m) == s);
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(dynamic_body,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(dynamic_body,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,10 +4,13 @@
|
||||
// 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 <beast/http/empty_body.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -17,3 +20,4 @@ BOOST_STATIC_ASSERT(is_body_writer<empty_body>::value);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+12
-8
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/http/error.hpp>
|
||||
#include <boost/beast/http/error.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -21,15 +24,15 @@ public:
|
||||
check(char const* name, error ev)
|
||||
{
|
||||
auto const ec = make_error_code(ev);
|
||||
BEAST_EXPECT(std::string(ec.category().name()) == name);
|
||||
BEAST_EXPECT(! ec.message().empty());
|
||||
BEAST_EXPECT(std::addressof(ec.category()) ==
|
||||
BOOST_BEAST_EXPECT(std::string(ec.category().name()) == name);
|
||||
BOOST_BEAST_EXPECT(! ec.message().empty());
|
||||
BOOST_BEAST_EXPECT(std::addressof(ec.category()) ==
|
||||
std::addressof(detail::get_http_error_category()));
|
||||
BEAST_EXPECT(detail::get_http_error_category().equivalent(
|
||||
BOOST_BEAST_EXPECT(detail::get_http_error_category().equivalent(
|
||||
static_cast<std::underlying_type<error>::type>(ev),
|
||||
ec.category().default_error_condition(
|
||||
static_cast<std::underlying_type<error>::type>(ev))));
|
||||
BEAST_EXPECT(detail::get_http_error_category().equivalent(
|
||||
BOOST_BEAST_EXPECT(detail::get_http_error_category().equivalent(
|
||||
ec, static_cast<std::underlying_type<error>::type>(ev)));
|
||||
}
|
||||
|
||||
@@ -62,7 +65,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(error,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(error,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+10
-6
@@ -4,12 +4,15 @@
|
||||
// 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 <beast/http/field.hpp>
|
||||
#include <boost/beast/http/field.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -22,8 +25,8 @@ public:
|
||||
auto const match =
|
||||
[&](field f, string_view s)
|
||||
{
|
||||
BEAST_EXPECT(iequals(to_string(f), s));
|
||||
BEAST_EXPECT(string_to_field(s) == f);
|
||||
BOOST_BEAST_EXPECT(iequals(to_string(f), s));
|
||||
BOOST_BEAST_EXPECT(string_to_field(s) == f);
|
||||
};
|
||||
|
||||
match(field::accept, "accept");
|
||||
@@ -386,7 +389,7 @@ public:
|
||||
auto const unknown =
|
||||
[&](string_view s)
|
||||
{
|
||||
BEAST_EXPECT(string_to_field(s) == field::unknown);
|
||||
BOOST_BEAST_EXPECT(string_to_field(s) == field::unknown);
|
||||
};
|
||||
unknown("");
|
||||
unknown("x");
|
||||
@@ -399,7 +402,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(field,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(field,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+238
-234
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/http/fields.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/type_traits.hpp>
|
||||
#include <beast/test/test_allocator.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
#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/lexical_cast.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -78,13 +81,13 @@ public:
|
||||
{
|
||||
{
|
||||
fields f;
|
||||
BEAST_EXPECT(f.begin() == f.end());
|
||||
BOOST_BEAST_EXPECT(f.begin() == f.end());
|
||||
}
|
||||
{
|
||||
unequal_t a1;
|
||||
basic_fields<unequal_t> f{a1};
|
||||
BEAST_EXPECT(f.get_allocator() == a1);
|
||||
BEAST_EXPECT(f.get_allocator() != unequal_t{});
|
||||
BOOST_BEAST_EXPECT(f.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(f.get_allocator() != unequal_t{});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,13 +95,13 @@ public:
|
||||
{
|
||||
{
|
||||
basic_fields<equal_t> f1;
|
||||
BEAST_EXPECT(f1.get_allocator()->nmove == 0);
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator()->nmove == 0);
|
||||
f1.insert("1", "1");
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
basic_fields<equal_t> f2{std::move(f1)};
|
||||
BEAST_EXPECT(f2.get_allocator()->nmove == 1);
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BEAST_EXPECT(f1["1"] == "");
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator()->nmove == 1);
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "");
|
||||
}
|
||||
// allocators equal
|
||||
{
|
||||
@@ -106,8 +109,8 @@ public:
|
||||
f1.insert("1", "1");
|
||||
equal_t a;
|
||||
basic_fields<equal_t> f2{std::move(f1), a};
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BEAST_EXPECT(f1["1"] == "");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "");
|
||||
}
|
||||
{
|
||||
// allocators unequal
|
||||
@@ -115,7 +118,7 @@ public:
|
||||
f1.insert("1", "1");
|
||||
unequal_t a;
|
||||
basic_fields<unequal_t> f2{std::move(f1), a};
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,34 +128,34 @@ public:
|
||||
basic_fields<equal_t> f1;
|
||||
f1.insert("1", "1");
|
||||
basic_fields<equal_t> f2{f1};
|
||||
BEAST_EXPECT(f1.get_allocator() == f2.get_allocator());
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() == f2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
basic_fields<unequal_t> f1;
|
||||
f1.insert("1", "1");
|
||||
unequal_t a;
|
||||
basic_fields<unequal_t> f2(f1, a);
|
||||
BEAST_EXPECT(f1.get_allocator() != f2.get_allocator());
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() != f2.get_allocator());
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
basic_fields<equal_t> f1;
|
||||
f1.insert("1", "1");
|
||||
basic_fields<unequal_t> f2(f1);
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
basic_fields<unequal_t> f1;
|
||||
f1.insert("1", "1");
|
||||
equal_t a;
|
||||
basic_fields<equal_t> f2(f1, a);
|
||||
BEAST_EXPECT(f2.get_allocator() == a);
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator() == a);
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +166,8 @@ public:
|
||||
f1.insert("1", "1");
|
||||
fields f2;
|
||||
f2 = std::move(f1);
|
||||
BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : true
|
||||
@@ -174,8 +177,8 @@ public:
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocma_t> f2;
|
||||
f2 = std::move(f1);
|
||||
BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_move_assignment : false
|
||||
@@ -185,8 +188,8 @@ public:
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocma_t> f2;
|
||||
f2 = std::move(f1);
|
||||
BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,11 +200,11 @@ public:
|
||||
f1.insert("1", "1");
|
||||
fields f2;
|
||||
f2 = f1;
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
basic_fields<equal_t> f3;
|
||||
f3 = f2;
|
||||
BEAST_EXPECT(f3["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f3["1"] == "1");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : true
|
||||
@@ -211,7 +214,7 @@ public:
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocca_t> f2;
|
||||
f2 = f1;
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
{
|
||||
// propagate_on_container_copy_assignment : false
|
||||
@@ -221,7 +224,7 @@ public:
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocca_t> f2;
|
||||
f2 = f1;
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,45 +235,45 @@ public:
|
||||
using pocs_t = test::test_allocator<char,
|
||||
false, true, true, true, true>;
|
||||
pocs_t a1, a2;
|
||||
BEAST_EXPECT(a1 != a2);
|
||||
BOOST_BEAST_EXPECT(a1 != a2);
|
||||
basic_fields<pocs_t> f1{a1};
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocs_t> f2{a2};
|
||||
BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
swap(f1, f2);
|
||||
BEAST_EXPECT(f1.get_allocator() == a2);
|
||||
BEAST_EXPECT(f2.get_allocator() == a1);
|
||||
BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
swap(f1, f2);
|
||||
BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2.begin() == f2.end());
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2.begin() == f2.end());
|
||||
}
|
||||
{
|
||||
// propagate_on_container_swap : false
|
||||
using pocs_t = test::test_allocator<char,
|
||||
true, true, true, false, true>;
|
||||
pocs_t a1, a2;
|
||||
BEAST_EXPECT(a1 == a2);
|
||||
BEAST_EXPECT(a1.id() != a2.id());
|
||||
BOOST_BEAST_EXPECT(a1 == a2);
|
||||
BOOST_BEAST_EXPECT(a1.id() != a2.id());
|
||||
basic_fields<pocs_t> f1{a1};
|
||||
f1.insert("1", "1");
|
||||
basic_fields<pocs_t> f2{a2};
|
||||
BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator() == a1);
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator() == a2);
|
||||
swap(f1, f2);
|
||||
BEAST_EXPECT(f1.get_allocator().id() == a1.id());
|
||||
BEAST_EXPECT(f2.get_allocator().id() == a2.id());
|
||||
BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BEAST_EXPECT(f2["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator().id() == a1.id());
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator().id() == a2.id());
|
||||
BOOST_BEAST_EXPECT(f1.begin() == f1.end());
|
||||
BOOST_BEAST_EXPECT(f2["1"] == "1");
|
||||
swap(f1, f2);
|
||||
BEAST_EXPECT(f1.get_allocator().id() == a1.id());
|
||||
BEAST_EXPECT(f2.get_allocator().id() == a2.id());
|
||||
BEAST_EXPECT(f1["1"] == "1");
|
||||
BEAST_EXPECT(f2.begin() == f2.end());
|
||||
BOOST_BEAST_EXPECT(f1.get_allocator().id() == a1.id());
|
||||
BOOST_BEAST_EXPECT(f2.get_allocator().id() == a2.id());
|
||||
BOOST_BEAST_EXPECT(f1["1"] == "1");
|
||||
BOOST_BEAST_EXPECT(f2.begin() == f2.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,35 +281,35 @@ public:
|
||||
{
|
||||
fields f;
|
||||
f.insert(field::user_agent, "x");
|
||||
BEAST_EXPECT(f.count(field::user_agent));
|
||||
BEAST_EXPECT(f.count(to_string(field::user_agent)));
|
||||
BEAST_EXPECT(f.count(field::user_agent) == 1);
|
||||
BEAST_EXPECT(f.count(to_string(field::user_agent)) == 1);
|
||||
BOOST_BEAST_EXPECT(f.count(field::user_agent));
|
||||
BOOST_BEAST_EXPECT(f.count(to_string(field::user_agent)));
|
||||
BOOST_BEAST_EXPECT(f.count(field::user_agent) == 1);
|
||||
BOOST_BEAST_EXPECT(f.count(to_string(field::user_agent)) == 1);
|
||||
f.insert(field::user_agent, "y");
|
||||
BEAST_EXPECT(f.count(field::user_agent) == 2);
|
||||
BOOST_BEAST_EXPECT(f.count(field::user_agent) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
void testHeaders()
|
||||
{
|
||||
f_t f1;
|
||||
BEAST_EXPECT(empty(f1));
|
||||
BOOST_BEAST_EXPECT(empty(f1));
|
||||
fill(1, f1);
|
||||
BEAST_EXPECT(size(f1) == 1);
|
||||
BOOST_BEAST_EXPECT(size(f1) == 1);
|
||||
f_t f2;
|
||||
f2 = f1;
|
||||
BEAST_EXPECT(size(f2) == 1);
|
||||
BOOST_BEAST_EXPECT(size(f2) == 1);
|
||||
f2.insert("2", "2");
|
||||
BEAST_EXPECT(std::distance(f2.begin(), f2.end()) == 2);
|
||||
BOOST_BEAST_EXPECT(std::distance(f2.begin(), f2.end()) == 2);
|
||||
f1 = std::move(f2);
|
||||
BEAST_EXPECT(size(f1) == 2);
|
||||
BEAST_EXPECT(size(f2) == 0);
|
||||
BOOST_BEAST_EXPECT(size(f1) == 2);
|
||||
BOOST_BEAST_EXPECT(size(f2) == 0);
|
||||
f_t f3(std::move(f1));
|
||||
BEAST_EXPECT(size(f3) == 2);
|
||||
BEAST_EXPECT(size(f1) == 0);
|
||||
BOOST_BEAST_EXPECT(size(f3) == 2);
|
||||
BOOST_BEAST_EXPECT(size(f1) == 0);
|
||||
self_assign(f3, std::move(f3));
|
||||
BEAST_EXPECT(size(f3) == 2);
|
||||
BEAST_EXPECT(f2.erase("Not-Present") == 0);
|
||||
BOOST_BEAST_EXPECT(size(f3) == 2);
|
||||
BOOST_BEAST_EXPECT(f2.erase("Not-Present") == 0);
|
||||
}
|
||||
|
||||
void testRFC2616()
|
||||
@@ -316,7 +319,7 @@ public:
|
||||
f.insert("a", "x");
|
||||
f.insert("aa", "y");
|
||||
f.insert("f", "z");
|
||||
BEAST_EXPECT(f.count("a") == 2);
|
||||
BOOST_BEAST_EXPECT(f.count("a") == 2);
|
||||
}
|
||||
|
||||
void testErase()
|
||||
@@ -326,9 +329,9 @@ public:
|
||||
f.insert("a", "x");
|
||||
f.insert("aa", "y");
|
||||
f.insert("f", "z");
|
||||
BEAST_EXPECT(size(f) == 4);
|
||||
BOOST_BEAST_EXPECT(size(f) == 4);
|
||||
f.erase("a");
|
||||
BEAST_EXPECT(size(f) == 2);
|
||||
BOOST_BEAST_EXPECT(size(f) == 2);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -341,21 +344,21 @@ public:
|
||||
f.insert(field::body, 2);
|
||||
f.insert(field::close, 3);
|
||||
f.insert(field::body, 4);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::age);
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::body);
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::body);
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::close);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "Body");
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "Body");
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "Close");
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
|
||||
BEAST_EXPECT(f.erase(field::body) == 2);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "Close");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::age);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::body);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::body);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::close);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "Body");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "Body");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "Close");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
|
||||
BOOST_BEAST_EXPECT(f.erase(field::body) == 2);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "Age");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "Close");
|
||||
}
|
||||
{
|
||||
// group fields, case insensitive
|
||||
@@ -364,21 +367,21 @@ public:
|
||||
f.insert("ab", 2);
|
||||
f.insert("b", 3);
|
||||
f.insert("AB", 4);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::unknown);
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::unknown);
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::unknown);
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::unknown);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "ab");
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "AB");
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "b");
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
|
||||
BEAST_EXPECT(f.erase("Ab") == 2);
|
||||
BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "b");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name() == field::unknown);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name() == field::unknown);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->name() == field::unknown);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->name() == field::unknown);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "ab");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "AB");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "b");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->value() == "1");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->value() == "2");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->value() == "4");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->value() == "3");
|
||||
BOOST_BEAST_EXPECT(f.erase("Ab") == 2);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "b");
|
||||
}
|
||||
{
|
||||
// verify insertion orde
|
||||
@@ -391,14 +394,14 @@ public:
|
||||
f.insert("Dd", 6);
|
||||
f.insert("DD", 7);
|
||||
f.insert( "e", 8);
|
||||
BEAST_EXPECT(f.count("dd") == 4);
|
||||
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "dd");
|
||||
BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "dD");
|
||||
BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "Dd");
|
||||
BEAST_EXPECT(std::next(f.begin(), 4)->name_string() == "DD");
|
||||
BOOST_BEAST_EXPECT(f.count("dd") == 4);
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "dd");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 2)->name_string() == "dD");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 3)->name_string() == "Dd");
|
||||
BOOST_BEAST_EXPECT(std::next(f.begin(), 4)->name_string() == "DD");
|
||||
f.set("dd", "-");
|
||||
BEAST_EXPECT(f.count("dd") == 1);
|
||||
BEAST_EXPECT(f["dd"] == "-");
|
||||
BOOST_BEAST_EXPECT(f.count("dd") == 1);
|
||||
BOOST_BEAST_EXPECT(f["dd"] == "-");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,25 +432,25 @@ public:
|
||||
req.method(verb::get);
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::content_length, "0");
|
||||
req.set(field::transfer_encoding, "chunked");
|
||||
req.prepare_payload();
|
||||
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::transfer_encoding, "deflate");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
|
||||
req.set(field::transfer_encoding, "deflate, chunked");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
}
|
||||
|
||||
// GET, sized
|
||||
@@ -458,19 +461,19 @@ public:
|
||||
req.body = 50;
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "");
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "");
|
||||
|
||||
req.set(field::content_length, "0");
|
||||
req.set(field::transfer_encoding, "chunked");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::transfer_encoding, "deflate, chunked");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
}
|
||||
|
||||
// PUT, empty
|
||||
@@ -480,14 +483,14 @@ public:
|
||||
req.method(verb::put);
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "0");
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "0");
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::content_length, "50");
|
||||
req.set(field::transfer_encoding, "deflate, chunked");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "0");
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "0");
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
}
|
||||
|
||||
// PUT, sized
|
||||
@@ -498,14 +501,14 @@ public:
|
||||
req.body = 50;
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::content_length, "25");
|
||||
req.set(field::transfer_encoding, "deflate, chunked");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
}
|
||||
|
||||
// POST, unsized
|
||||
@@ -515,13 +518,13 @@ public:
|
||||
req.method(verb::post);
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "chunked");
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "chunked");
|
||||
|
||||
req.set(field::transfer_encoding, "deflate");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate, chunked");
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate, chunked");
|
||||
}
|
||||
|
||||
// POST, unsized HTTP/1.0
|
||||
@@ -531,13 +534,13 @@ public:
|
||||
req.method(verb::post);
|
||||
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req.count(field::transfer_encoding) == 0);
|
||||
|
||||
req.set(field::transfer_encoding, "deflate");
|
||||
req.prepare_payload();
|
||||
BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
BOOST_BEAST_EXPECT(req.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(req[field::transfer_encoding] == "deflate");
|
||||
}
|
||||
|
||||
// OK, empty
|
||||
@@ -546,14 +549,14 @@ public:
|
||||
res.version = 11;
|
||||
|
||||
res.prepare_payload();
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
res.erase(field::content_length);
|
||||
res.set(field::transfer_encoding, "chunked");
|
||||
res.prepare_payload();
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
}
|
||||
|
||||
// OK, sized
|
||||
@@ -563,14 +566,14 @@ public:
|
||||
res.body = 50;
|
||||
|
||||
res.prepare_payload();
|
||||
BEAST_EXPECT(res[field::content_length] == "50");
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
res.erase(field::content_length);
|
||||
res.set(field::transfer_encoding, "chunked");
|
||||
res.prepare_payload();
|
||||
BEAST_EXPECT(res[field::content_length] == "50");
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "50");
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
}
|
||||
|
||||
// OK, unsized
|
||||
@@ -579,8 +582,8 @@ public:
|
||||
res.version = 11;
|
||||
|
||||
res.prepare_payload();
|
||||
BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,7 +595,7 @@ public:
|
||||
[&](bool v)
|
||||
{
|
||||
res.keep_alive(v);
|
||||
BEAST_EXPECT(
|
||||
BOOST_BEAST_EXPECT(
|
||||
(res.keep_alive() && v) ||
|
||||
(! res.keep_alive() && ! v));
|
||||
};
|
||||
@@ -605,70 +608,70 @@ public:
|
||||
res.erase(field::connection);
|
||||
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "keep-alive");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "keep-alive, close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.erase(field::connection);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
|
||||
res.set(field::connection, "close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
|
||||
res.set(field::connection, "keep-alive");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
|
||||
res.set(field::connection, "keep-alive, close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive");
|
||||
|
||||
auto const test10 =
|
||||
[&](std::string s)
|
||||
{
|
||||
res.set(field::connection, s);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, s + ", close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s + ", close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, s);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s + ", keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s + ", keep-alive");
|
||||
|
||||
res.set(field::connection, s + ", close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s + ", keep-alive");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s + ", keep-alive");
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive, " + s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive, " + s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s+ ", close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == "keep-alive, " + s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "keep-alive, " + s);
|
||||
};
|
||||
|
||||
test10("foo");
|
||||
@@ -679,70 +682,70 @@ public:
|
||||
|
||||
res.erase(field::connection);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "keep-alive");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.set(field::connection, "keep-alive, close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::connection) == 0);
|
||||
|
||||
res.erase(field::connection);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close");
|
||||
|
||||
res.set(field::connection, "close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close");
|
||||
|
||||
res.set(field::connection, "keep-alive");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close");
|
||||
|
||||
res.set(field::connection, "keep-alive, close");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close");
|
||||
|
||||
auto const test11 =
|
||||
[&](std::string s)
|
||||
{
|
||||
res.set(field::connection, s);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, s + ", close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s);
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s + ", close");
|
||||
keep_alive(true);
|
||||
BEAST_EXPECT(res[field::connection] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s);
|
||||
|
||||
res.set(field::connection, s);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s + ", close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s + ", close");
|
||||
|
||||
res.set(field::connection, "close, " + s);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close, " + s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close, " + s);
|
||||
|
||||
res.set(field::connection, "keep-alive, " + s);
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == s + ", close");
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == s + ", close");
|
||||
|
||||
res.set(field::connection, "close, " + s + ", keep-alive");
|
||||
keep_alive(false);
|
||||
BEAST_EXPECT(res[field::connection] == "close, " + s);
|
||||
BOOST_BEAST_EXPECT(res[field::connection] == "close, " + s);
|
||||
};
|
||||
|
||||
test11("foo");
|
||||
@@ -753,79 +756,79 @@ public:
|
||||
testContentLength()
|
||||
{
|
||||
response<empty_body> res{status::ok, 11};
|
||||
BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
res.content_length(0);
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
|
||||
res.content_length(100);
|
||||
BEAST_EXPECT(res[field::content_length] == "100");
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "100");
|
||||
|
||||
res.content_length(boost::none);
|
||||
BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
|
||||
res.set(field::transfer_encoding, "chunked");
|
||||
res.content_length(0);
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_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);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "100");
|
||||
BOOST_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);
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
auto const check = [&](std::string s)
|
||||
{
|
||||
res.set(field::transfer_encoding, s);
|
||||
res.content_length(0);
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_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);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "100");
|
||||
BOOST_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);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
|
||||
res.set(field::transfer_encoding, s + ", chunked");
|
||||
res.content_length(0);
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_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);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "100");
|
||||
BOOST_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);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == s);
|
||||
|
||||
res.set(field::transfer_encoding, "chunked, " + s);
|
||||
res.content_length(0);
|
||||
BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, " + s);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "0");
|
||||
BOOST_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);
|
||||
BOOST_BEAST_EXPECT(res[field::content_length] == "100");
|
||||
BOOST_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);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, " + s);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked, " + s);
|
||||
};
|
||||
|
||||
check("foo");
|
||||
@@ -840,63 +843,63 @@ public:
|
||||
testChunked()
|
||||
{
|
||||
response<empty_body> res{status::ok, 11};
|
||||
BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::content_length) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
auto const chunked =
|
||||
[&](bool v)
|
||||
{
|
||||
res.chunked(v);
|
||||
BEAST_EXPECT(
|
||||
BOOST_BEAST_EXPECT(
|
||||
(res.chunked() && v) ||
|
||||
(! res.chunked() && ! v));
|
||||
BEAST_EXPECT(res.count(
|
||||
BOOST_BEAST_EXPECT(res.count(
|
||||
field::content_length) == 0);
|
||||
};
|
||||
|
||||
res.erase(field::transfer_encoding);
|
||||
res.set(field::content_length, 32);
|
||||
chunked(true);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
|
||||
res.set(field::transfer_encoding, "chunked");
|
||||
chunked(true);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked");
|
||||
|
||||
res.erase(field::transfer_encoding);
|
||||
res.set(field::content_length, 32);
|
||||
chunked(false);
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
res.set(field::transfer_encoding, "chunked");
|
||||
chunked(false);
|
||||
BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
BOOST_BEAST_EXPECT(res.count(field::transfer_encoding) == 0);
|
||||
|
||||
|
||||
|
||||
res.set(field::transfer_encoding, "foo");
|
||||
chunked(true);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "foo, chunked");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "foo, chunked");
|
||||
|
||||
res.set(field::transfer_encoding, "chunked, foo");
|
||||
chunked(true);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo, chunked");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo, chunked");
|
||||
|
||||
res.set(field::transfer_encoding, "chunked, foo, chunked");
|
||||
chunked(true);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo, chunked");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo, chunked");
|
||||
|
||||
res.set(field::transfer_encoding, "foo, chunked");
|
||||
chunked(false);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "foo");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "foo");
|
||||
|
||||
res.set(field::transfer_encoding, "chunked, foo");
|
||||
chunked(false);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo");
|
||||
|
||||
res.set(field::transfer_encoding, "chunked, foo, chunked");
|
||||
chunked(false);
|
||||
BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo");
|
||||
BOOST_BEAST_EXPECT(res[field::transfer_encoding] == "chunked, foo");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -915,7 +918,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(fields,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(fields,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+23
-19
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/http/file_body.hpp>
|
||||
#include <boost/beast/http/file_body.hpp>
|
||||
|
||||
#include <beast/core/file_stdio.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/serializer.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/file_stdio.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
#include <boost/beast/http/serializer.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -53,22 +56,22 @@ public:
|
||||
|
||||
p.get().body.open(
|
||||
temp.string<std::string>().c_str(), file_mode::write, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
|
||||
p.put(boost::asio::buffer(s.data(), s.size()), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
{
|
||||
File f;
|
||||
f.open(temp.string<std::string>().c_str(), file_mode::read, ec);
|
||||
auto size = f.size(ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(size == 3);
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(size == 3);
|
||||
std::string s1;
|
||||
s1.resize(3);
|
||||
f.read(&s1[0], s1.size(), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECTS(s1 == "xyz", s);
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(s1 == "xyz", s);
|
||||
}
|
||||
{
|
||||
lambda visit;
|
||||
@@ -77,36 +80,37 @@ public:
|
||||
res.set(field::server, "test");
|
||||
res.body.open(temp.string<std::string>().c_str(),
|
||||
file_mode::scan, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
res.prepare_payload();
|
||||
|
||||
serializer<false, basic_file_body<File>, fields> sr{res};
|
||||
sr.next(ec, visit);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
auto const cb = *visit.buffer.data().begin();
|
||||
string_view const s1{
|
||||
boost::asio::buffer_cast<char const*>(cb),
|
||||
boost::asio::buffer_size(cb)};
|
||||
BEAST_EXPECTS(s1 == s, s1);
|
||||
BOOST_BEAST_EXPECTS(s1 == s, s1);
|
||||
}
|
||||
}
|
||||
boost::filesystem::remove(temp, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
void
|
||||
run() override
|
||||
{
|
||||
doTestFileBody<file_stdio>();
|
||||
#if BEAST_USE_WIN32_FILE
|
||||
#if BOOST_BEAST_USE_WIN32_FILE
|
||||
doTestFileBody<file_win32>();
|
||||
#endif
|
||||
#if BEAST_USE_POSIX_FILE
|
||||
#if BOOST_BEAST_USE_POSIX_FILE
|
||||
doTestFileBody<file_posix>();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(file_body,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(file_body,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+82
-78
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/http/message.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -123,26 +126,26 @@ public:
|
||||
{
|
||||
Arg1 arg1;
|
||||
request<one_arg_body>{verb::get, "/", 11, std::move(arg1)};
|
||||
BEAST_EXPECT(arg1.moved);
|
||||
BOOST_BEAST_EXPECT(arg1.moved);
|
||||
}
|
||||
|
||||
{
|
||||
header<true> h;
|
||||
h.set(field::user_agent, "test");
|
||||
BEAST_EXPECT(h[field::user_agent] == "test");
|
||||
BOOST_BEAST_EXPECT(h[field::user_agent] == "test");
|
||||
request<default_body> m{std::move(h)};
|
||||
BEAST_EXPECT(m[field::user_agent] == "test");
|
||||
BEAST_EXPECT(h.count(field::user_agent) == 0);
|
||||
BOOST_BEAST_EXPECT(m[field::user_agent] == "test");
|
||||
BOOST_BEAST_EXPECT(h.count(field::user_agent) == 0);
|
||||
}
|
||||
{
|
||||
request<empty_body> h{verb::get, "/", 10};
|
||||
h.set(field::user_agent, "test");
|
||||
request<one_arg_body> m{std::move(h.base()), Arg1{}};
|
||||
BEAST_EXPECT(m["User-Agent"] == "test");
|
||||
BEAST_EXPECT(h.count(http::field::user_agent) == 0);
|
||||
BEAST_EXPECT(m.method() == verb::get);
|
||||
BEAST_EXPECT(m.target() == "/");
|
||||
BEAST_EXPECT(m.version == 10);
|
||||
BOOST_BEAST_EXPECT(m["User-Agent"] == "test");
|
||||
BOOST_BEAST_EXPECT(h.count(http::field::user_agent) == 0);
|
||||
BOOST_BEAST_EXPECT(m.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(m.target() == "/");
|
||||
BOOST_BEAST_EXPECT(m.version == 10);
|
||||
}
|
||||
|
||||
// swap
|
||||
@@ -154,14 +157,14 @@ public:
|
||||
m2.method_string("G");
|
||||
m2.body = "2";
|
||||
swap(m1, m2);
|
||||
BEAST_EXPECT(m1.method_string() == "G");
|
||||
BEAST_EXPECT(m2.method_string().empty());
|
||||
BEAST_EXPECT(m1.target().empty());
|
||||
BEAST_EXPECT(m2.target() == "u");
|
||||
BEAST_EXPECT(m1.body == "2");
|
||||
BEAST_EXPECT(m2.body == "1");
|
||||
BEAST_EXPECT(! m1.count("h"));
|
||||
BEAST_EXPECT(m2.count("h"));
|
||||
BOOST_BEAST_EXPECT(m1.method_string() == "G");
|
||||
BOOST_BEAST_EXPECT(m2.method_string().empty());
|
||||
BOOST_BEAST_EXPECT(m1.target().empty());
|
||||
BOOST_BEAST_EXPECT(m2.target() == "u");
|
||||
BOOST_BEAST_EXPECT(m1.body == "2");
|
||||
BOOST_BEAST_EXPECT(m2.body == "1");
|
||||
BOOST_BEAST_EXPECT(! m1.count("h"));
|
||||
BOOST_BEAST_EXPECT(m2.count("h"));
|
||||
}
|
||||
|
||||
struct MoveFields : fields
|
||||
@@ -209,57 +212,57 @@ public:
|
||||
{
|
||||
{
|
||||
request<empty_body> req;
|
||||
BEAST_EXPECT(req.version == 11);
|
||||
BEAST_EXPECT(req.method() == verb::unknown);
|
||||
BEAST_EXPECT(req.target() == "");
|
||||
BOOST_BEAST_EXPECT(req.version == 11);
|
||||
BOOST_BEAST_EXPECT(req.method() == verb::unknown);
|
||||
BOOST_BEAST_EXPECT(req.target() == "");
|
||||
}
|
||||
{
|
||||
request<empty_body> req{verb::get, "/", 11};
|
||||
BEAST_EXPECT(req.version == 11);
|
||||
BEAST_EXPECT(req.method() == verb::get);
|
||||
BEAST_EXPECT(req.target() == "/");
|
||||
BOOST_BEAST_EXPECT(req.version == 11);
|
||||
BOOST_BEAST_EXPECT(req.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(req.target() == "/");
|
||||
}
|
||||
{
|
||||
request<string_body> req{verb::get, "/", 11, "Hello"};
|
||||
BEAST_EXPECT(req.version == 11);
|
||||
BEAST_EXPECT(req.method() == verb::get);
|
||||
BEAST_EXPECT(req.target() == "/");
|
||||
BEAST_EXPECT(req.body == "Hello");
|
||||
BOOST_BEAST_EXPECT(req.version == 11);
|
||||
BOOST_BEAST_EXPECT(req.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(req.target() == "/");
|
||||
BOOST_BEAST_EXPECT(req.body == "Hello");
|
||||
}
|
||||
{
|
||||
request<string_body, test_fields> req{
|
||||
verb::get, "/", 11, "Hello", token{}};
|
||||
BEAST_EXPECT(req.version == 11);
|
||||
BEAST_EXPECT(req.method() == verb::get);
|
||||
BEAST_EXPECT(req.target() == "/");
|
||||
BEAST_EXPECT(req.body == "Hello");
|
||||
BOOST_BEAST_EXPECT(req.version == 11);
|
||||
BOOST_BEAST_EXPECT(req.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(req.target() == "/");
|
||||
BOOST_BEAST_EXPECT(req.body == "Hello");
|
||||
}
|
||||
{
|
||||
response<string_body> res;
|
||||
BEAST_EXPECT(res.version == 11);
|
||||
BEAST_EXPECT(res.result() == status::ok);
|
||||
BEAST_EXPECT(res.reason() == "OK");
|
||||
BOOST_BEAST_EXPECT(res.version == 11);
|
||||
BOOST_BEAST_EXPECT(res.result() == status::ok);
|
||||
BOOST_BEAST_EXPECT(res.reason() == "OK");
|
||||
}
|
||||
{
|
||||
response<string_body> res{status::bad_request, 10};
|
||||
BEAST_EXPECT(res.version == 10);
|
||||
BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
BOOST_BEAST_EXPECT(res.version == 10);
|
||||
BOOST_BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BOOST_BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
}
|
||||
{
|
||||
response<string_body> res{status::bad_request, 10, "Hello"};
|
||||
BEAST_EXPECT(res.version == 10);
|
||||
BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
BEAST_EXPECT(res.body == "Hello");
|
||||
BOOST_BEAST_EXPECT(res.version == 10);
|
||||
BOOST_BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BOOST_BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
BOOST_BEAST_EXPECT(res.body == "Hello");
|
||||
}
|
||||
{
|
||||
response<string_body, test_fields> res{
|
||||
status::bad_request, 10, "Hello", token{}};
|
||||
BEAST_EXPECT(res.version == 10);
|
||||
BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
BEAST_EXPECT(res.body == "Hello");
|
||||
BOOST_BEAST_EXPECT(res.version == 10);
|
||||
BOOST_BEAST_EXPECT(res.result() == status::bad_request);
|
||||
BOOST_BEAST_EXPECT(res.reason() == "Bad Request");
|
||||
BOOST_BEAST_EXPECT(res.body == "Hello");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,18 +279,18 @@ public:
|
||||
m2.body = "2";
|
||||
m2.version = 11;
|
||||
swap(m1, m2);
|
||||
BEAST_EXPECT(m1.result() == status::not_found);
|
||||
BEAST_EXPECT(m1.result_int() == 404);
|
||||
BEAST_EXPECT(m2.result() == status::ok);
|
||||
BEAST_EXPECT(m2.result_int() == 200);
|
||||
BEAST_EXPECT(m1.reason() == "Not Found");
|
||||
BEAST_EXPECT(m2.reason() == "OK");
|
||||
BEAST_EXPECT(m1.version == 11);
|
||||
BEAST_EXPECT(m2.version == 10);
|
||||
BEAST_EXPECT(m1.body == "2");
|
||||
BEAST_EXPECT(m2.body == "1");
|
||||
BEAST_EXPECT(! m1.count("h"));
|
||||
BEAST_EXPECT(m2.count("h"));
|
||||
BOOST_BEAST_EXPECT(m1.result() == status::not_found);
|
||||
BOOST_BEAST_EXPECT(m1.result_int() == 404);
|
||||
BOOST_BEAST_EXPECT(m2.result() == status::ok);
|
||||
BOOST_BEAST_EXPECT(m2.result_int() == 200);
|
||||
BOOST_BEAST_EXPECT(m1.reason() == "Not Found");
|
||||
BOOST_BEAST_EXPECT(m2.reason() == "OK");
|
||||
BOOST_BEAST_EXPECT(m1.version == 11);
|
||||
BOOST_BEAST_EXPECT(m2.version == 10);
|
||||
BOOST_BEAST_EXPECT(m1.body == "2");
|
||||
BOOST_BEAST_EXPECT(m2.body == "1");
|
||||
BOOST_BEAST_EXPECT(! m1.count("h"));
|
||||
BOOST_BEAST_EXPECT(m2.count("h"));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -311,15 +314,15 @@ public:
|
||||
[&](verb v)
|
||||
{
|
||||
h.method(v);
|
||||
BEAST_EXPECT(h.method() == v);
|
||||
BEAST_EXPECT(h.method_string() == to_string(v));
|
||||
BOOST_BEAST_EXPECT(h.method() == v);
|
||||
BOOST_BEAST_EXPECT(h.method_string() == to_string(v));
|
||||
};
|
||||
auto const scheck =
|
||||
[&](string_view s)
|
||||
{
|
||||
h.method_string(s);
|
||||
BEAST_EXPECT(h.method() == string_to_verb(s));
|
||||
BEAST_EXPECT(h.method_string() == s);
|
||||
BOOST_BEAST_EXPECT(h.method() == string_to_verb(s));
|
||||
BOOST_BEAST_EXPECT(h.method_string() == s);
|
||||
};
|
||||
vcheck(verb::get);
|
||||
vcheck(verb::head);
|
||||
@@ -333,14 +336,14 @@ public:
|
||||
{
|
||||
header<false> h;
|
||||
h.result(200);
|
||||
BEAST_EXPECT(h.result_int() == 200);
|
||||
BEAST_EXPECT(h.result() == status::ok);
|
||||
BOOST_BEAST_EXPECT(h.result_int() == 200);
|
||||
BOOST_BEAST_EXPECT(h.result() == status::ok);
|
||||
h.result(status::switching_protocols);
|
||||
BEAST_EXPECT(h.result_int() == 101);
|
||||
BEAST_EXPECT(h.result() == status::switching_protocols);
|
||||
BOOST_BEAST_EXPECT(h.result_int() == 101);
|
||||
BOOST_BEAST_EXPECT(h.result() == status::switching_protocols);
|
||||
h.result(1);
|
||||
BEAST_EXPECT(h.result_int() == 1);
|
||||
BEAST_EXPECT(h.result() == status::unknown);
|
||||
BOOST_BEAST_EXPECT(h.result_int() == 1);
|
||||
BOOST_BEAST_EXPECT(h.result() == status::unknown);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -348,13 +351,13 @@ public:
|
||||
{
|
||||
header<false> h;
|
||||
h.result(status::ok);
|
||||
BEAST_EXPECT(h.reason() == "OK");
|
||||
BOOST_BEAST_EXPECT(h.reason() == "OK");
|
||||
h.reason("Pepe");
|
||||
BEAST_EXPECT(h.reason() == "Pepe");
|
||||
BOOST_BEAST_EXPECT(h.reason() == "Pepe");
|
||||
h.result(status::not_found);
|
||||
BEAST_EXPECT(h.reason() == "Pepe");
|
||||
BOOST_BEAST_EXPECT(h.reason() == "Pepe");
|
||||
h.reason({});
|
||||
BEAST_EXPECT(h.reason() == "Not Found");
|
||||
BOOST_BEAST_EXPECT(h.reason() == "Not Found");
|
||||
}
|
||||
|
||||
void
|
||||
@@ -370,7 +373,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(message,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(message,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,16 +4,19 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef BEAST_HTTP_TEST_MESSAGE_FUZZ_HPP
|
||||
#define BEAST_HTTP_TEST_MESSAGE_FUZZ_HPP
|
||||
#ifndef BOOST_BEAST_HTTP_TEST_MESSAGE_FUZZ_HPP
|
||||
#define BOOST_BEAST_HTTP_TEST_MESSAGE_FUZZ_HPP
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/http/detail/rfc7230.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/http/detail/rfc7230.hpp>
|
||||
#include <cstdint>
|
||||
#include <random>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -600,5 +603,6 @@ chunkExtensionsTest(
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
+80
-77
@@ -4,24 +4,27 @@
|
||||
// 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 <beast/http/parser.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/string_ostream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/core/consuming_buffers.hpp>
|
||||
#include <beast/core/flat_buffer.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/string_ostream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/core/consuming_buffers.hpp>
|
||||
#include <boost/beast/core/flat_buffer.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -80,7 +83,7 @@ public:
|
||||
error_code ec;
|
||||
parser_type<isRequest> p;
|
||||
put(buffer(s.data(), s.size()), p, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
return;
|
||||
f(p);
|
||||
}
|
||||
@@ -96,22 +99,22 @@ public:
|
||||
s.remove_prefix(used);
|
||||
if(ec == error::need_more)
|
||||
ec.assign(0, ec.category());
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
BEAST_EXPECT(! p.is_done());
|
||||
BOOST_BEAST_EXPECT(! p.is_done());
|
||||
used = p.put(
|
||||
buffer(s.data(), s.size()), ec);
|
||||
s.remove_prefix(used);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
BEAST_EXPECT(s.empty());
|
||||
BOOST_BEAST_EXPECT(s.empty());
|
||||
if(p.need_eof())
|
||||
{
|
||||
p.put_eof(ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
}
|
||||
if(BEAST_EXPECT(p.is_done()))
|
||||
if(BOOST_BEAST_EXPECT(p.is_done()))
|
||||
f(p);
|
||||
}
|
||||
}
|
||||
@@ -127,14 +130,14 @@ public:
|
||||
[&](parser_type<false> const& p)
|
||||
{
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(! p.is_chunked());
|
||||
BEAST_EXPECT(p.need_eof());
|
||||
BEAST_EXPECT(p.content_length() == boost::none);
|
||||
BEAST_EXPECT(m.version == 10);
|
||||
BEAST_EXPECT(m.result() == status::ok);
|
||||
BEAST_EXPECT(m.reason() == "OK");
|
||||
BEAST_EXPECT(m["Server"] == "test");
|
||||
BEAST_EXPECT(m.body == "Hello, world!");
|
||||
BOOST_BEAST_EXPECT(! p.is_chunked());
|
||||
BOOST_BEAST_EXPECT(p.need_eof());
|
||||
BOOST_BEAST_EXPECT(p.content_length() == boost::none);
|
||||
BOOST_BEAST_EXPECT(m.version == 10);
|
||||
BOOST_BEAST_EXPECT(m.result() == status::ok);
|
||||
BOOST_BEAST_EXPECT(m.reason() == "OK");
|
||||
BOOST_BEAST_EXPECT(m["Server"] == "test");
|
||||
BOOST_BEAST_EXPECT(m.body == "Hello, world!");
|
||||
}
|
||||
);
|
||||
doMatrix<false>(
|
||||
@@ -154,17 +157,17 @@ public:
|
||||
[&](parser_type<false> const& p)
|
||||
{
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(! p.need_eof());
|
||||
BEAST_EXPECT(p.is_chunked());
|
||||
BEAST_EXPECT(p.content_length() == boost::none);
|
||||
BEAST_EXPECT(m.version == 11);
|
||||
BEAST_EXPECT(m.result() == status::ok);
|
||||
BEAST_EXPECT(m.reason() == "OK");
|
||||
BEAST_EXPECT(m["Server"] == "test");
|
||||
BEAST_EXPECT(m["Transfer-Encoding"] == "chunked");
|
||||
BEAST_EXPECT(m["Expires"] == "never");
|
||||
BEAST_EXPECT(m["MD5-Fingerprint"] == "-");
|
||||
BEAST_EXPECT(m.body == "*****--");
|
||||
BOOST_BEAST_EXPECT(! p.need_eof());
|
||||
BOOST_BEAST_EXPECT(p.is_chunked());
|
||||
BOOST_BEAST_EXPECT(p.content_length() == boost::none);
|
||||
BOOST_BEAST_EXPECT(m.version == 11);
|
||||
BOOST_BEAST_EXPECT(m.result() == status::ok);
|
||||
BOOST_BEAST_EXPECT(m.reason() == "OK");
|
||||
BOOST_BEAST_EXPECT(m["Server"] == "test");
|
||||
BOOST_BEAST_EXPECT(m["Transfer-Encoding"] == "chunked");
|
||||
BOOST_BEAST_EXPECT(m["Expires"] == "never");
|
||||
BOOST_BEAST_EXPECT(m["MD5-Fingerprint"] == "-");
|
||||
BOOST_BEAST_EXPECT(m.body == "*****--");
|
||||
}
|
||||
);
|
||||
doMatrix<false>(
|
||||
@@ -176,7 +179,7 @@ public:
|
||||
[&](parser_type<false> const& p)
|
||||
{
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(m.body == "*****");
|
||||
BOOST_BEAST_EXPECT(m.body == "*****");
|
||||
}
|
||||
);
|
||||
doMatrix<true>(
|
||||
@@ -186,12 +189,12 @@ public:
|
||||
[&](parser_type<true> const& p)
|
||||
{
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(m.method() == verb::get);
|
||||
BEAST_EXPECT(m.target() == "/");
|
||||
BEAST_EXPECT(m.version == 11);
|
||||
BEAST_EXPECT(! p.need_eof());
|
||||
BEAST_EXPECT(! p.is_chunked());
|
||||
BEAST_EXPECT(p.content_length() == boost::none);
|
||||
BOOST_BEAST_EXPECT(m.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(m.target() == "/");
|
||||
BOOST_BEAST_EXPECT(m.version == 11);
|
||||
BOOST_BEAST_EXPECT(! p.need_eof());
|
||||
BOOST_BEAST_EXPECT(! p.is_chunked());
|
||||
BOOST_BEAST_EXPECT(p.content_length() == boost::none);
|
||||
}
|
||||
);
|
||||
doMatrix<true>(
|
||||
@@ -202,7 +205,7 @@ public:
|
||||
[&](parser_type<true> const& p)
|
||||
{
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(m["X"] == "x");
|
||||
BOOST_BEAST_EXPECT(m["X"] == "x");
|
||||
}
|
||||
);
|
||||
|
||||
@@ -219,15 +222,15 @@ public:
|
||||
"*")
|
||||
, ec);
|
||||
auto const& m = p.get();
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BEAST_EXPECT(p.is_header_done());
|
||||
BEAST_EXPECT(! p.need_eof());
|
||||
BEAST_EXPECT(m.method() == verb::get);
|
||||
BEAST_EXPECT(m.target() == "/");
|
||||
BEAST_EXPECT(m.version == 11);
|
||||
BEAST_EXPECT(m["User-Agent"] == "test");
|
||||
BEAST_EXPECT(m.body == "*");
|
||||
BOOST_BEAST_EXPECT(! ec);
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.is_header_done());
|
||||
BOOST_BEAST_EXPECT(! p.need_eof());
|
||||
BOOST_BEAST_EXPECT(m.method() == verb::get);
|
||||
BOOST_BEAST_EXPECT(m.target() == "/");
|
||||
BOOST_BEAST_EXPECT(m.version == 11);
|
||||
BOOST_BEAST_EXPECT(m["User-Agent"] == "test");
|
||||
BOOST_BEAST_EXPECT(m.body == "*");
|
||||
}
|
||||
{
|
||||
// test partial parsing of final chunk
|
||||
@@ -244,9 +247,9 @@ public:
|
||||
"*";
|
||||
auto used = p.put(b.data(), ec);
|
||||
b.consume(used);
|
||||
BEAST_EXPECT(! ec);
|
||||
BEAST_EXPECT(! p.is_done());
|
||||
BEAST_EXPECT(p.get().body == "*");
|
||||
BOOST_BEAST_EXPECT(! ec);
|
||||
BOOST_BEAST_EXPECT(! p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.get().body == "*");
|
||||
ostream(b) <<
|
||||
"\r\n"
|
||||
"0;d;e=3;f=\"4\"\r\n"
|
||||
@@ -255,15 +258,15 @@ public:
|
||||
// incomplete parse, missing the final crlf
|
||||
used = p.put(b.data(), ec);
|
||||
b.consume(used);
|
||||
BEAST_EXPECT(ec == error::need_more);
|
||||
BOOST_BEAST_EXPECT(ec == error::need_more);
|
||||
ec.assign(0, ec.category());
|
||||
BEAST_EXPECT(! p.is_done());
|
||||
BOOST_BEAST_EXPECT(! p.is_done());
|
||||
ostream(b) <<
|
||||
"\r\n"; // final crlf to end message
|
||||
used = p.put(b.data(), ec);
|
||||
b.consume(used);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
}
|
||||
// skip body
|
||||
{
|
||||
@@ -276,10 +279,10 @@ public:
|
||||
"\r\n"
|
||||
"*****")
|
||||
, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BEAST_EXPECT(p.is_header_done());
|
||||
BEAST_EXPECT(p.content_length() &&
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.is_header_done());
|
||||
BOOST_BEAST_EXPECT(p.content_length() &&
|
||||
*p.content_length() == 5);
|
||||
}
|
||||
}
|
||||
@@ -298,17 +301,17 @@ public:
|
||||
ostream(b) <<
|
||||
"GET / HTTP/1.1\r\n";
|
||||
used = p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(ec == error::need_more, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::need_more, ec.message());
|
||||
b.consume(used);
|
||||
ec.assign(0, ec.category());
|
||||
ostream(b) <<
|
||||
"User-Agent: test\r\n"
|
||||
"\r\n";
|
||||
used = p.put(b.data(), ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
b.consume(used);
|
||||
BEAST_EXPECT(p.is_done());
|
||||
BEAST_EXPECT(p.is_header_done());
|
||||
BOOST_BEAST_EXPECT(p.is_done());
|
||||
BOOST_BEAST_EXPECT(p.is_header_done());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,14 +321,14 @@ public:
|
||||
error_code ec;
|
||||
parser_type<true> p;
|
||||
auto used = p.put(buf(""), ec);
|
||||
BEAST_EXPECT(ec == error::need_more);
|
||||
BEAST_EXPECT(! p.got_some());
|
||||
BEAST_EXPECT(used == 0);
|
||||
BOOST_BEAST_EXPECT(ec == error::need_more);
|
||||
BOOST_BEAST_EXPECT(! p.got_some());
|
||||
BOOST_BEAST_EXPECT(used == 0);
|
||||
ec.assign(0, ec.category());
|
||||
used = p.put(buf("G"), ec);
|
||||
BEAST_EXPECT(ec == error::need_more);
|
||||
BEAST_EXPECT(p.got_some());
|
||||
BEAST_EXPECT(used == 0);
|
||||
BOOST_BEAST_EXPECT(ec == error::need_more);
|
||||
BOOST_BEAST_EXPECT(p.got_some());
|
||||
BOOST_BEAST_EXPECT(used == 0);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -338,8 +341,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(parser,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(parser,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+39
-35
@@ -4,26 +4,29 @@
|
||||
// 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 <beast/http/read.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
|
||||
#include "test_parser.hpp"
|
||||
|
||||
#include <beast/core/ostream.hpp>
|
||||
#include <beast/core/flat_static_buffer.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/dynamic_body.hpp>
|
||||
#include <beast/http/parser.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/pipe_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/core/ostream.hpp>
|
||||
#include <boost/beast/core/flat_static_buffer.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/http/dynamic_body.hpp>
|
||||
#include <boost/beast/http/parser.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/test/fail_stream.hpp>
|
||||
#include <boost/beast/test/pipe_stream.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/spawn.hpp>
|
||||
#include <atomic>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -55,7 +58,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
static std::size_t constexpr pre = 10;
|
||||
@@ -71,7 +74,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
multi_buffer b;
|
||||
@@ -86,7 +89,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
static std::size_t constexpr pre = 10;
|
||||
@@ -102,7 +105,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void testThrow()
|
||||
@@ -162,7 +165,7 @@ public:
|
||||
flat_static_buffer<10> b;
|
||||
request<string_body> req;
|
||||
read(p.server, b, req, ec);
|
||||
BEAST_EXPECTS(ec == error::buffer_overflow,
|
||||
BOOST_BEAST_EXPECTS(ec == error::buffer_overflow,
|
||||
ec.message());
|
||||
}
|
||||
}
|
||||
@@ -254,7 +257,7 @@ public:
|
||||
{
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -272,7 +275,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -290,7 +293,7 @@ public:
|
||||
if(! ec)
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -302,7 +305,7 @@ public:
|
||||
request_parser<dynamic_body> p;
|
||||
error_code ec;
|
||||
read(ss, b, p, ec);
|
||||
BEAST_EXPECT(ec == http::error::end_of_stream);
|
||||
BOOST_BEAST_EXPECT(ec == http::error::end_of_stream);
|
||||
}
|
||||
{
|
||||
multi_buffer b;
|
||||
@@ -310,7 +313,7 @@ public:
|
||||
request_parser<dynamic_body> p;
|
||||
error_code ec;
|
||||
async_read(ss, b, p, do_yield[ec]);
|
||||
BEAST_EXPECT(ec == http::error::end_of_stream);
|
||||
BOOST_BEAST_EXPECT(ec == http::error::end_of_stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,17 +337,17 @@ public:
|
||||
boost::asio::io_service ios;
|
||||
test::string_istream is{ios,
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
multi_buffer b;
|
||||
request<dynamic_body> m;
|
||||
async_read(is, b, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.stop();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.reset();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.run_one();
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
{
|
||||
// Make sure uninvoked handlers are
|
||||
@@ -353,13 +356,13 @@ public:
|
||||
boost::asio::io_service ios;
|
||||
test::string_istream is{ios,
|
||||
"GET / HTTP/1.1\r\n\r\n"};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
multi_buffer b;
|
||||
request<dynamic_body> m;
|
||||
async_read(is, b, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
}
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,7 +383,7 @@ public:
|
||||
flat_buffer fb;
|
||||
parser<false, dynamic_body> p;
|
||||
read(c.server, fb, p, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -399,7 +402,7 @@ public:
|
||||
ostream(c.server.buffer) << s;
|
||||
c.server.read_size(n);
|
||||
read(c.server, b, p, ec);
|
||||
if(! BEAST_EXPECTS(! ec, ec.message()))
|
||||
if(! BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
continue;
|
||||
pred(p);
|
||||
}
|
||||
@@ -417,7 +420,7 @@ public:
|
||||
"0\r\n\r\n"
|
||||
,[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "abcd");
|
||||
BOOST_BEAST_EXPECT(p.body == "abcd");
|
||||
});
|
||||
readgrind<test_parser<false>>(
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
@@ -435,7 +438,7 @@ public:
|
||||
"\r\n"
|
||||
,[&](test_parser<false> const& p)
|
||||
{
|
||||
BEAST_EXPECT(p.body == "*****--");
|
||||
BOOST_BEAST_EXPECT(p.body == "*****--");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -458,7 +461,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(read,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(read,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+27
-23
@@ -4,17 +4,20 @@
|
||||
// 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 <beast/http/rfc7230.hpp>
|
||||
#include <boost/beast/http/rfc7230.hpp>
|
||||
|
||||
#include <beast/http/detail/rfc7230.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/detail/rfc7230.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <beast/core/detail/empty_base_optimization.hpp>
|
||||
#include <boost/beast/core/detail/empty_base_optimization.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -60,7 +63,7 @@ public:
|
||||
[&](std::string const& s)
|
||||
{
|
||||
auto const got = str(param_list{s});
|
||||
BEAST_EXPECTS(got == s, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == s, fmt(got));
|
||||
};
|
||||
auto const cs =
|
||||
[&](std::string const& s, std::string const& answer)
|
||||
@@ -68,13 +71,13 @@ public:
|
||||
ce(answer);
|
||||
auto const got = str(param_list{s});
|
||||
ce(got);
|
||||
BEAST_EXPECTS(got == answer, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == answer, fmt(got));
|
||||
};
|
||||
auto const cq =
|
||||
[&](std::string const& s, std::string const& answer)
|
||||
{
|
||||
auto const got = str(param_list{s});
|
||||
BEAST_EXPECTS(got == answer, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == answer, fmt(got));
|
||||
};
|
||||
|
||||
ce("");
|
||||
@@ -119,7 +122,7 @@ public:
|
||||
[&](std::string const& s)
|
||||
{
|
||||
auto const got = str(ext_list{s});
|
||||
BEAST_EXPECTS(got == s, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == s, fmt(got));
|
||||
};
|
||||
auto const cs =
|
||||
[&](std::string const& s, std::string const& good)
|
||||
@@ -127,13 +130,13 @@ public:
|
||||
ce(good);
|
||||
auto const got = str(ext_list{s});
|
||||
ce(got);
|
||||
BEAST_EXPECTS(got == good, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == good, fmt(got));
|
||||
};
|
||||
auto const cq =
|
||||
[&](std::string const& s, std::string const& good)
|
||||
{
|
||||
auto const got = str(ext_list{s});
|
||||
BEAST_EXPECTS(got == good, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == good, fmt(got));
|
||||
};
|
||||
/*
|
||||
ext-basic_parsed_list = *( "," OWS ) ext *( OWS "," [ OWS ext ] )
|
||||
@@ -169,9 +172,9 @@ public:
|
||||
cq("ab;x=\" \"", "ab;x= ");
|
||||
cq("ab;x=\"\\\"\"", "ab;x=\"");
|
||||
|
||||
BEAST_EXPECT(ext_list{"a,b;i=1,c;j=2;k=3"}.exists("A"));
|
||||
BEAST_EXPECT(ext_list{"a,b;i=1,c;j=2;k=3"}.exists("b"));
|
||||
BEAST_EXPECT(! ext_list{"a,b;i=1,c;j=2;k=3"}.exists("d"));
|
||||
BOOST_BEAST_EXPECT(ext_list{"a,b;i=1,c;j=2;k=3"}.exists("A"));
|
||||
BOOST_BEAST_EXPECT(ext_list{"a,b;i=1,c;j=2;k=3"}.exists("b"));
|
||||
BOOST_BEAST_EXPECT(! ext_list{"a,b;i=1,c;j=2;k=3"}.exists("d"));
|
||||
|
||||
// invalid strings
|
||||
cs("i j", "i");
|
||||
@@ -201,7 +204,7 @@ public:
|
||||
[&](std::string const& s)
|
||||
{
|
||||
auto const got = str(token_list{s});
|
||||
BEAST_EXPECTS(got == s, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == s, fmt(got));
|
||||
};
|
||||
auto const cs =
|
||||
[&](std::string const& s, std::string const& good)
|
||||
@@ -209,7 +212,7 @@ public:
|
||||
ce(good);
|
||||
auto const got = str(token_list{s});
|
||||
ce(got);
|
||||
BEAST_EXPECTS(got == good, fmt(got));
|
||||
BOOST_BEAST_EXPECTS(got == good, fmt(got));
|
||||
};
|
||||
|
||||
cs("", "");
|
||||
@@ -230,9 +233,9 @@ public:
|
||||
cs("x ,\ty ", "x,y");
|
||||
cs("x, y, z", "x,y,z");
|
||||
|
||||
BEAST_EXPECT(token_list{"a,b,c"}.exists("A"));
|
||||
BEAST_EXPECT(token_list{"a,b,c"}.exists("b"));
|
||||
BEAST_EXPECT(! token_list{"a,b,c"}.exists("d"));
|
||||
BOOST_BEAST_EXPECT(token_list{"a,b,c"}.exists("A"));
|
||||
BOOST_BEAST_EXPECT(token_list{"a,b,c"}.exists("b"));
|
||||
BOOST_BEAST_EXPECT(! token_list{"a,b,c"}.exists("d"));
|
||||
|
||||
// invalid
|
||||
cs("x y", "x");
|
||||
@@ -256,14 +259,14 @@ public:
|
||||
validate(string_view in,
|
||||
std::vector<std::string> const& v)
|
||||
{
|
||||
BEAST_EXPECT(to_vector<Policy>(in) == v);
|
||||
BOOST_BEAST_EXPECT(to_vector<Policy>(in) == v);
|
||||
}
|
||||
|
||||
template<class Policy>
|
||||
void
|
||||
good(string_view in)
|
||||
{
|
||||
BEAST_EXPECT(validate_list(
|
||||
BOOST_BEAST_EXPECT(validate_list(
|
||||
detail::basic_parsed_list<Policy>{in}));
|
||||
}
|
||||
|
||||
@@ -272,7 +275,7 @@ public:
|
||||
good(string_view in,
|
||||
std::vector<std::string> const& v)
|
||||
{
|
||||
BEAST_EXPECT(validate_list(
|
||||
BOOST_BEAST_EXPECT(validate_list(
|
||||
detail::basic_parsed_list<Policy>{in}));
|
||||
validate<Policy>(in, v);
|
||||
}
|
||||
@@ -281,7 +284,7 @@ public:
|
||||
void
|
||||
bad(string_view in)
|
||||
{
|
||||
BEAST_EXPECT(! validate_list(
|
||||
BOOST_BEAST_EXPECT(! validate_list(
|
||||
detail::basic_parsed_list<Policy>{in}));
|
||||
}
|
||||
|
||||
@@ -351,7 +354,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(rfc7230,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(rfc7230,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/http/serializer.hpp>
|
||||
#include <boost/beast/http/serializer.hpp>
|
||||
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -105,7 +108,7 @@ public:
|
||||
for(;;)
|
||||
{
|
||||
sr.next(ec, visit);
|
||||
BEAST_EXPECT(visit.size <= limit);
|
||||
BOOST_BEAST_EXPECT(visit.size <= limit);
|
||||
sr.consume(visit.size);
|
||||
if(sr.is_done())
|
||||
break;
|
||||
@@ -119,7 +122,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(serializer,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(serializer,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+23
-19
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/http/span_body.hpp>
|
||||
#include <boost/beast/http/span_body.hpp>
|
||||
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -24,23 +27,23 @@ struct span_body_test
|
||||
using B = span_body<char const>;
|
||||
request<B> req;
|
||||
|
||||
BEAST_EXPECT(req.body.size() == 0);
|
||||
BEAST_EXPECT(B::size(req.body) == 0);
|
||||
BOOST_BEAST_EXPECT(req.body.size() == 0);
|
||||
BOOST_BEAST_EXPECT(B::size(req.body) == 0);
|
||||
|
||||
req.body = B::value_type("xyz", 3);
|
||||
BEAST_EXPECT(req.body.size() == 3);
|
||||
BEAST_EXPECT(B::size(req.body) == 3);
|
||||
BOOST_BEAST_EXPECT(req.body.size() == 3);
|
||||
BOOST_BEAST_EXPECT(B::size(req.body) == 3);
|
||||
|
||||
B::reader r{req};
|
||||
error_code ec;
|
||||
r.init(ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
auto const buf = r.get(ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
if(! BEAST_EXPECT(buf != boost::none))
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
if(! BOOST_BEAST_EXPECT(buf != boost::none))
|
||||
return;
|
||||
BEAST_EXPECT(boost::asio::buffer_size(buf->first) == 3);
|
||||
BEAST_EXPECT(! buf->second);
|
||||
BOOST_BEAST_EXPECT(boost::asio::buffer_size(buf->first) == 3);
|
||||
BOOST_BEAST_EXPECT(! buf->second);
|
||||
}
|
||||
{
|
||||
char buf[5];
|
||||
@@ -50,16 +53,16 @@ struct span_body_test
|
||||
B::writer w{req};
|
||||
error_code ec;
|
||||
w.init(boost::none, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
w.put(boost::asio::const_buffers_1{
|
||||
"123", 3}, ec);
|
||||
BEAST_EXPECTS(! ec, ec.message());
|
||||
BEAST_EXPECT(buf[0] == '1');
|
||||
BEAST_EXPECT(buf[1] == '2');
|
||||
BEAST_EXPECT(buf[2] == '3');
|
||||
BOOST_BEAST_EXPECTS(! ec, ec.message());
|
||||
BOOST_BEAST_EXPECT(buf[0] == '1');
|
||||
BOOST_BEAST_EXPECT(buf[1] == '2');
|
||||
BOOST_BEAST_EXPECT(buf[2] == '3');
|
||||
w.put(boost::asio::const_buffers_1{
|
||||
"456", 3}, ec);
|
||||
BEAST_EXPECTS(ec == error::buffer_overflow, ec.message());
|
||||
BOOST_BEAST_EXPECTS(ec == error::buffer_overflow, ec.message());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +73,8 @@ struct span_body_test
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(span_body,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(span_body,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+13
-9
@@ -4,12 +4,15 @@
|
||||
// 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 <beast/http/status.hpp>
|
||||
#include <boost/beast/http/status.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -22,9 +25,9 @@ public:
|
||||
{
|
||||
auto const check = [&](status s, int i, status_class sc)
|
||||
{
|
||||
BEAST_EXPECT(int_to_status(i) == s);
|
||||
BEAST_EXPECT(to_status_class(i) == sc);
|
||||
BEAST_EXPECT(to_status_class(int_to_status(i)) == sc);
|
||||
BOOST_BEAST_EXPECT(int_to_status(i) == s);
|
||||
BOOST_BEAST_EXPECT(to_status_class(i) == sc);
|
||||
BOOST_BEAST_EXPECT(to_status_class(int_to_status(i)) == sc);
|
||||
};
|
||||
check(status::continue_ ,100, status_class::informational);
|
||||
check(status::switching_protocols ,101, status_class::informational);
|
||||
@@ -93,13 +96,13 @@ public:
|
||||
check(status::network_authentication_required ,511, status_class::server_error);
|
||||
check(status::network_connect_timeout_error ,599, status_class::server_error);
|
||||
|
||||
BEAST_EXPECT(to_status_class(1) == status_class::unknown);
|
||||
BEAST_EXPECT(to_status_class(status::unknown) == status_class::unknown);
|
||||
BOOST_BEAST_EXPECT(to_status_class(1) == status_class::unknown);
|
||||
BOOST_BEAST_EXPECT(to_status_class(status::unknown) == status_class::unknown);
|
||||
|
||||
auto const good =
|
||||
[&](status v)
|
||||
{
|
||||
BEAST_EXPECT(obsolete_reason(v) != "Unknown Status");
|
||||
BOOST_BEAST_EXPECT(obsolete_reason(v) != "Unknown Status");
|
||||
};
|
||||
good(status::continue_);
|
||||
good(status::switching_protocols);
|
||||
@@ -169,8 +172,9 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(status,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(status,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
// 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 <beast/http/string_body.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -17,3 +20,4 @@ BOOST_STATIC_ASSERT(is_body_writer<string_body>::value);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,15 +4,18 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef BEAST_HTTP_TEST_PARSER_HPP
|
||||
#define BEAST_HTTP_TEST_PARSER_HPP
|
||||
#ifndef BOOST_BEAST_HTTP_TEST_PARSER_HPP
|
||||
#define BOOST_BEAST_HTTP_TEST_PARSER_HPP
|
||||
|
||||
#include <beast/http/basic_parser.hpp>
|
||||
#include <beast/test/fail_counter.hpp>
|
||||
#include <boost/beast/http/basic_parser.hpp>
|
||||
#include <boost/beast/test/fail_counter.hpp>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -171,5 +174,6 @@ public:
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
|
||||
#endif
|
||||
@@ -4,13 +4,16 @@
|
||||
// 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 <beast/http/type_traits.hpp>
|
||||
#include <boost/beast/http/type_traits.hpp>
|
||||
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -30,3 +33,4 @@ BOOST_STATIC_ASSERT(! is_fields<not_fields>::value);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -4,10 +4,13 @@
|
||||
// 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 <beast/http/vector_body.hpp>
|
||||
#include <boost/beast/http/vector_body.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -17,3 +20,4 @@ BOOST_STATIC_ASSERT(is_body_writer<vector_body<char>>::value);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
+9
-6
@@ -4,12 +4,15 @@
|
||||
// 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 <beast/http/verb.hpp>
|
||||
#include <boost/beast/http/verb.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -23,7 +26,7 @@ public:
|
||||
auto const good =
|
||||
[&](verb v)
|
||||
{
|
||||
BEAST_EXPECT(string_to_verb(to_string(v)) == v);
|
||||
BOOST_BEAST_EXPECT(string_to_verb(to_string(v)) == v);
|
||||
};
|
||||
|
||||
good(verb::unknown);
|
||||
@@ -66,7 +69,7 @@ public:
|
||||
[&](string_view s)
|
||||
{
|
||||
auto const v = string_to_verb(s);
|
||||
BEAST_EXPECTS(v == verb::unknown, to_string(v));
|
||||
BOOST_BEAST_EXPECTS(v == verb::unknown, to_string(v));
|
||||
};
|
||||
|
||||
bad("AC_");
|
||||
@@ -121,8 +124,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(verb,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(verb,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
} // boost
|
||||
+60
-56
@@ -4,28 +4,31 @@
|
||||
// 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 <beast/http/write.hpp>
|
||||
#include <boost/beast/http/write.hpp>
|
||||
|
||||
#include <beast/http/buffer_body.hpp>
|
||||
#include <beast/http/empty_body.hpp>
|
||||
#include <beast/http/fields.hpp>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/string_body.hpp>
|
||||
#include <beast/core/error.hpp>
|
||||
#include <beast/core/multi_buffer.hpp>
|
||||
#include <beast/test/fail_stream.hpp>
|
||||
#include <beast/test/pipe_stream.hpp>
|
||||
#include <beast/test/string_istream.hpp>
|
||||
#include <beast/test/string_ostream.hpp>
|
||||
#include <beast/test/yield_to.hpp>
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <boost/beast/http/buffer_body.hpp>
|
||||
#include <boost/beast/http/empty_body.hpp>
|
||||
#include <boost/beast/http/fields.hpp>
|
||||
#include <boost/beast/http/message.hpp>
|
||||
#include <boost/beast/http/read.hpp>
|
||||
#include <boost/beast/http/string_body.hpp>
|
||||
#include <boost/beast/core/error.hpp>
|
||||
#include <boost/beast/core/multi_buffer.hpp>
|
||||
#include <boost/beast/test/fail_stream.hpp>
|
||||
#include <boost/beast/test/pipe_stream.hpp>
|
||||
#include <boost/beast/test/string_istream.hpp>
|
||||
#include <boost/beast/test/string_ostream.hpp>
|
||||
#include <boost/beast/test/yield_to.hpp>
|
||||
#include <boost/beast/unit_test/suite.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
namespace boost {
|
||||
namespace beast {
|
||||
namespace http {
|
||||
|
||||
@@ -300,8 +303,8 @@ public:
|
||||
error_code ec;
|
||||
test::string_ostream ss{ios_};
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(BEAST_EXPECTS(ec == error::end_of_stream, ec.message()))
|
||||
BEAST_EXPECT(ss.str ==
|
||||
if(BOOST_BEAST_EXPECTS(ec == error::end_of_stream, ec.message()))
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Content-Length: 5\r\n"
|
||||
@@ -318,8 +321,8 @@ public:
|
||||
error_code ec;
|
||||
test::string_ostream ss(ios_);
|
||||
async_write(ss, m, do_yield[ec]);
|
||||
if(BEAST_EXPECTS(! ec, ec.message()))
|
||||
BEAST_EXPECT(ss.str ==
|
||||
if(BOOST_BEAST_EXPECTS(! ec, ec.message()))
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -349,7 +352,7 @@ public:
|
||||
try
|
||||
{
|
||||
write(fs, m);
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -364,7 +367,7 @@ public:
|
||||
{
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -379,7 +382,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(ec == error::end_of_stream)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -394,7 +397,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -409,7 +412,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(ec == error::end_of_stream)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -424,7 +427,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -440,7 +443,7 @@ public:
|
||||
write(fs, m, ec);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -451,7 +454,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
|
||||
for(n = 0; n < limit; ++n)
|
||||
{
|
||||
@@ -467,7 +470,7 @@ public:
|
||||
async_write(fs, m, do_yield[ec]);
|
||||
if(! ec)
|
||||
{
|
||||
BEAST_EXPECT(fs.next_layer().str ==
|
||||
BOOST_BEAST_EXPECT(fs.next_layer().str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Connection: keep-alive\r\n"
|
||||
@@ -478,7 +481,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(n < limit);
|
||||
BOOST_BEAST_EXPECT(n < limit);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -493,7 +496,7 @@ public:
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
m.prepare_payload();
|
||||
BEAST_EXPECT(str(m) ==
|
||||
BOOST_BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -513,8 +516,8 @@ public:
|
||||
test::string_ostream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
BEAST_EXPECT(ec == error::end_of_stream);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
BOOST_BEAST_EXPECT(ec == error::end_of_stream);
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.0\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"\r\n"
|
||||
@@ -530,7 +533,7 @@ public:
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
m.prepare_payload();
|
||||
BEAST_EXPECT(str(m) ==
|
||||
BOOST_BEAST_EXPECT(str(m) ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Content-Length: 1\r\n"
|
||||
@@ -550,7 +553,7 @@ public:
|
||||
test::string_ostream ss(ios_);
|
||||
error_code ec;
|
||||
write(ss, m, ec);
|
||||
BEAST_EXPECT(ss.str ==
|
||||
BOOST_BEAST_EXPECT(ss.str ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"User-Agent: test\r\n"
|
||||
"Transfer-Encoding: chunked\r\n"
|
||||
@@ -571,7 +574,7 @@ public:
|
||||
m.version = 11;
|
||||
m.set(field::user_agent, "test");
|
||||
m.body = "*";
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(m) ==
|
||||
BOOST_BEAST_EXPECT(boost::lexical_cast<std::string>(m) ==
|
||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
||||
}
|
||||
|
||||
@@ -594,7 +597,7 @@ public:
|
||||
// after calling io_service::stop
|
||||
boost::asio::io_service ios;
|
||||
test::string_ostream os{ios};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.version = 11;
|
||||
@@ -602,13 +605,13 @@ public:
|
||||
m.set("Content-Length", 5);
|
||||
m.body = "*****";
|
||||
async_write(os, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.stop();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.reset();
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
ios.run_one();
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
{
|
||||
// Make sure uninvoked handlers are
|
||||
@@ -616,7 +619,7 @@ public:
|
||||
{
|
||||
boost::asio::io_service ios;
|
||||
test::string_ostream is{ios};
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.version = 11;
|
||||
@@ -624,9 +627,9 @@ public:
|
||||
m.set("Content-Length", 5);
|
||||
m.body = "*****";
|
||||
async_write(is, m, handler{});
|
||||
BEAST_EXPECT(handler::count() > 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() > 0);
|
||||
}
|
||||
BEAST_EXPECT(handler::count() == 0);
|
||||
BOOST_BEAST_EXPECT(handler::count() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +649,7 @@ public:
|
||||
write_some(stream, sr, ec);
|
||||
if(ec)
|
||||
return;
|
||||
BEAST_EXPECT(stream.nwrite <= 1);
|
||||
BOOST_BEAST_EXPECT(stream.nwrite <= 1);
|
||||
if(sr.is_done())
|
||||
break;
|
||||
}
|
||||
@@ -669,7 +672,7 @@ public:
|
||||
async_write_some(stream, sr, yield[ec]);
|
||||
if(ec)
|
||||
return;
|
||||
BEAST_EXPECT(stream.nwrite <= 1);
|
||||
BOOST_BEAST_EXPECT(stream.nwrite <= 1);
|
||||
if(sr.is_done())
|
||||
break;
|
||||
}
|
||||
@@ -699,8 +702,8 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_write(p.client, m, ec);
|
||||
BEAST_EXPECT(p.server.str() == result);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(p.server.str() == result);
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -708,8 +711,8 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_async_write(p.client, m, ec, yield);
|
||||
BEAST_EXPECT(p.server.str() == result);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(p.server.str() == result);
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -724,7 +727,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
{
|
||||
@@ -738,7 +741,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
}
|
||||
@@ -748,7 +751,7 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_write(p.client, m, ec);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -756,7 +759,7 @@ public:
|
||||
auto m = m0;
|
||||
error_code ec;
|
||||
do_async_write(p.client, m, ec, yield);
|
||||
BEAST_EXPECT(equal_body<false>(
|
||||
BOOST_BEAST_EXPECT(equal_body<false>(
|
||||
p.server.str(), m.body.s));
|
||||
p.server.clear();
|
||||
}
|
||||
@@ -772,7 +775,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
{
|
||||
@@ -786,7 +789,7 @@ public:
|
||||
if(sr.is_header_done())
|
||||
break;
|
||||
}
|
||||
BEAST_EXPECT(! m.body.read);
|
||||
BOOST_BEAST_EXPECT(! m.body.read);
|
||||
p.server.clear();
|
||||
}
|
||||
}
|
||||
@@ -832,7 +835,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(write,http,beast);
|
||||
BOOST_BEAST_DEFINE_TESTSUITE(write,http,beast);
|
||||
|
||||
} // http
|
||||
} // beast
|
||||
} // boost
|
||||
@@ -1,17 +1,25 @@
|
||||
# Part of Beast
|
||||
#
|
||||
# Copyright (c) 2013-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)
|
||||
#
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
GroupSources(example/server-framework framework)
|
||||
GroupSources(example/common common)
|
||||
GroupSources(extras/beast extras)
|
||||
GroupSources(include/beast beast)
|
||||
GroupSources(extras/boost/beast extras)
|
||||
GroupSources(include/boost/beast beast)
|
||||
|
||||
GroupSources(test/server "/")
|
||||
|
||||
add_executable (server-test
|
||||
${BEAST_INCLUDES}
|
||||
${BOOST_BEAST_INCLUDES}
|
||||
${COMMON_INCLUDES}
|
||||
${SERVER_INCLUDES}
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
Jamfile
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
file_service.cpp
|
||||
framework.cpp
|
||||
http_async_port.cpp
|
||||
|
||||
+3
-1
@@ -4,9 +4,11 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
unit-test server-test :
|
||||
../../extras/beast/unit_test/main.cpp
|
||||
../../extras/boost/beast/unit_test/main.cpp
|
||||
file_service.cpp
|
||||
framework.cpp
|
||||
http_async_port.cpp
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/file_service.hpp"
|
||||
#include "example/server-framework/file_service.hpp"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/framework.hpp"
|
||||
#include "example/server-framework/framework.hpp"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/http_async_port.hpp"
|
||||
#include "example/server-framework/http_async_port.hpp"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/http_base.hpp"
|
||||
#include "example/server-framework/http_base.hpp"
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/http_sync_port.hpp"
|
||||
#include "example/server-framework/http_sync_port.hpp"
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#if BEAST_USE_OPENSSL
|
||||
#if BOOST_BEAST_USE_OPENSSL
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "../../example/server-framework/https_ports.hpp"
|
||||
#include "example/server-framework/https_ports.hpp"
|
||||
|
||||
#endif
|
||||
@@ -4,11 +4,13 @@
|
||||
// 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
|
||||
//
|
||||
|
||||
#if BEAST_USE_OPENSSL
|
||||
#if BOOST_BEAST_USE_OPENSSL
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include "../../example/server-framework/multi_port.hpp"
|
||||
#include "example/server-framework/multi_port.hpp"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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 "../../example/server-framework/server.hpp"
|
||||
#include "example/server-framework/server.hpp"
|
||||
|
||||
Loaded 100 of 375 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user