forked from boostorg/beast
Refactor chunked parsing (API Change):
* parser now has a callback feature for intercepting chunk headers and chunk bodies * The names for basic_parser derived class callbacks have been refactored * basic_parser offers an additional callback for distinguishing chunk body data. Actions Required: * Adjust signatures for required members of user-defined subclasses of basic_parser * Use the new basic_parser chunk callbacks for accessing chunk extensions and chunk bodies.
This commit is contained in:
1 parent
cc73d883be
commit
4b71aa67e0
27 files changed
+1851
-269
No files matched your search
@@ -44,6 +44,7 @@ add_executable (core-tests
|
||||
base64.cpp
|
||||
empty_base_optimization.cpp
|
||||
sha1.cpp
|
||||
detail/varint.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(core-tests
|
||||
|
||||
@@ -38,4 +38,5 @@ unit-test core-tests :
|
||||
base64.cpp
|
||||
empty_base_optimization.cpp
|
||||
sha1.cpp
|
||||
detail/varint.cpp
|
||||
;
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/core/detail/varint.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
|
||||
namespace beast {
|
||||
|
||||
class varint_test : public beast::unit_test::suite
|
||||
{
|
||||
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(;;)
|
||||
{
|
||||
char buf[16];
|
||||
BOOST_ASSERT(sizeof(buf) >= varint_size(n0));
|
||||
auto it = &buf[0];
|
||||
varint_write(it, n0);
|
||||
it = &buf[0];
|
||||
auto n = varint_read(it);
|
||||
BEAST_EXPECT(n == n0);
|
||||
n = n0 + n1;
|
||||
if(n < n1)
|
||||
break;
|
||||
n0 = n1;
|
||||
n1 = n;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
testVarint();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(varint,core,beast);
|
||||
|
||||
} // beast
|
||||
Reference in new issue
Block a user