Use BOOST_ASSERT

This commit is contained in:
Vinnie Falco committed 2017-07-20 08:12:09 -07:00
1 parent 58d3ea6548
commit dff2751c07
20 files changed
+73 -72

No files matched your search

+7 -7
View File
@@ -15,8 +15,8 @@
#include <beast/core/static_streambuf.hpp>
#include <beast/core/static_string.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/assert.hpp>
#include <boost/endian/buffers.hpp>
#include <cassert>
#include <cstdint>
namespace beast {
@@ -175,7 +175,7 @@ read_fh1(frame_header& fh, DynamicBuffer& db,
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
std::uint8_t b[2];
assert(buffer_size(db.data()) >= sizeof(b));
BOOST_ASSERT(buffer_size(db.data()) >= sizeof(b));
db.consume(buffer_copy(buffer(b), db.data()));
std::size_t need;
fh.len = b[1] & 0x7f;
@@ -250,7 +250,7 @@ read_fh2(frame_header& fh, DynamicBuffer& db,
case 126:
{
std::uint8_t b[2];
assert(buffer_size(db.data()) >= sizeof(b));
BOOST_ASSERT(buffer_size(db.data()) >= sizeof(b));
db.consume(buffer_copy(buffer(b), db.data()));
fh.len = big_uint16_to_native(&b[0]);
// length not canonical
@@ -264,7 +264,7 @@ read_fh2(frame_header& fh, DynamicBuffer& db,
case 127:
{
std::uint8_t b[8];
assert(buffer_size(db.data()) >= sizeof(b));
BOOST_ASSERT(buffer_size(db.data()) >= sizeof(b));
db.consume(buffer_copy(buffer(b), db.data()));
fh.len = big_uint64_to_native(&b[0]);
// length not canonical
@@ -279,7 +279,7 @@ read_fh2(frame_header& fh, DynamicBuffer& db,
if(fh.mask)
{
std::uint8_t b[4];
assert(buffer_size(db.data()) >= sizeof(b));
BOOST_ASSERT(buffer_size(db.data()) >= sizeof(b));
db.consume(buffer_copy(buffer(b), db.data()));
fh.key = little_uint32_to_native(&b[0]);
}
@@ -301,7 +301,7 @@ read(ping_data& data, Buffers const& bs)
using boost::asio::buffer_copy;
using boost::asio::buffer_size;
using boost::asio::mutable_buffers_1;
assert(buffer_size(bs) <= data.max_size());
BOOST_ASSERT(buffer_size(bs) <= data.max_size());
data.resize(buffer_size(bs));
buffer_copy(mutable_buffers_1{
data.data(), data.size()}, bs);
@@ -320,7 +320,7 @@ read(close_reason& cr,
using boost::asio::buffer_size;
using namespace boost::endian;
auto n = buffer_size(bs);
assert(n <= 125);
BOOST_ASSERT(n <= 125);
if(n == 0)
{
cr = close_reason{};
+4 -4
View File
@@ -8,8 +8,8 @@
#ifndef BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP
#define BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP
#include <boost/assert.hpp>
#include <array>
#include <cassert>
#include <memory>
#include <new>
#include <utility>
@@ -80,7 +80,7 @@ public:
// Engaged invokables must be invoked before
// destruction otherwise the io_service
// invariants are broken w.r.t completions.
assert(! base_);
BOOST_ASSERT(! base_);
}
#endif
@@ -102,7 +102,7 @@ public:
// Engaged invokables must be invoked before
// assignment otherwise the io_service
// invariants are broken w.r.t completions.
assert(! base_);
BOOST_ASSERT(! base_);
if(other.base_)
{
@@ -135,7 +135,7 @@ invokable::emplace(F&& f)
{
static_assert(sizeof(buf_type) >= sizeof(holder<F>),
"buffer too small");
assert(! base_);
BOOST_ASSERT(! base_);
::new(buf_) holder<F>(std::forward<F>(f));
base_ = reinterpret_cast<base*>(&buf_[0]);
}
@@ -19,7 +19,7 @@
#include <beast/http/message.hpp>
#include <beast/http/string_body.hpp>
#include <boost/asio/error.hpp>
#include <cassert>
#include <boost/assert.hpp>
#include <cstdint>
#include <functional>
#include <limits>
+1 -1
View File
@@ -14,7 +14,7 @@
#include <beast/http/read.hpp>
#include <beast/core/handler_alloc.hpp>
#include <beast/core/prepare_buffers.hpp>
#include <cassert>
#include <boost/assert.hpp>
#include <memory>
#include <type_traits>
+1 -1
View File
@@ -155,7 +155,7 @@ operator()(error_code ec, bool again)
// send close frame
d.state = 99;
d.ws.wr_close_ = true;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
d.fb.data(), std::move(*this));
@@ -13,7 +13,7 @@
#include <beast/http/read.hpp>
#include <beast/http/write.hpp>
#include <beast/core/handler_alloc.hpp>
#include <cassert>
#include <boost/assert.hpp>
#include <memory>
namespace beast {
+1 -1
View File
@@ -154,7 +154,7 @@ operator()(error_code ec, bool again)
case 1:
// send ping frame
d.state = 99;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
d.fb.data(), std::move(*this));
@@ -12,8 +12,8 @@
#include <beast/core/handler_alloc.hpp>
#include <beast/core/prepare_buffers.hpp>
#include <beast/core/static_streambuf.hpp>
#include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <cassert>
#include <memory>
namespace beast {
@@ -330,7 +330,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
{
// suspend
d.state = do_pong_resume;
assert(d.ws.wr_block_ != &d);
BOOST_ASSERT(d.ws.wr_block_ != &d);
d.ws.rd_op_.template emplace<
read_frame_op>(std::move(*this));
return;
@@ -349,7 +349,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
d.state = do_read_fh;
break;
}
assert(d.ws.rd_fh_.op == opcode::close);
BOOST_ASSERT(d.ws.rd_fh_.op == opcode::close);
{
detail::read(d.ws.cr_, d.fb.data(), code);
if(code != close_code::none)
@@ -413,7 +413,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
}
// send pong
d.state = do_pong + 1;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
d.fb.data(), std::move(*this));
@@ -455,7 +455,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
case do_close:
d.state = do_close + 1;
d.ws.wr_close_ = true;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
d.fb.data(), std::move(*this));
@@ -498,7 +498,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again)
// send close frame
d.state = do_fail + 4;
d.ws.wr_close_ = true;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
d.fb.data(), std::move(*this));
+3 -3
View File
@@ -29,9 +29,9 @@
#include <beast/core/prepare_buffers.hpp>
#include <beast/core/static_streambuf.hpp>
#include <beast/core/stream_concepts.hpp>
#include <boost/assert.hpp>
#include <boost/endian/buffers.hpp>
#include <algorithm>
#include <cassert>
#include <memory>
#include <utility>
@@ -411,7 +411,7 @@ close(close_reason const& cr, error_code& ec)
{
static_assert(is_SyncStream<next_layer_type>::value,
"SyncStream requirements not met");
assert(! wr_close_);
BOOST_ASSERT(! wr_close_);
wr_close_ = true;
detail::frame_streambuf fb;
write_close<static_streambuf>(fb, cr);
@@ -608,7 +608,7 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec)
pong_cb_(payload);
continue;
}
assert(rd_fh_.op == opcode::close);
BOOST_ASSERT(rd_fh_.op == opcode::close);
{
detail::read(cr_, fb.data(), code);
if(code != close_code::none)
@@ -14,8 +14,8 @@
#include <beast/core/handler_alloc.hpp>
#include <beast/core/static_streambuf.hpp>
#include <beast/websocket/detail/frame.hpp>
#include <boost/assert.hpp>
#include <algorithm>
#include <cassert>
#include <memory>
namespace beast {
@@ -199,7 +199,7 @@ operator()(error_code ec, bool again)
{
// send header and entire payload
d.state = 99;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
buffer_cat(d.fh_buf.data(), d.cb),
@@ -215,7 +215,7 @@ operator()(error_code ec, bool again)
detail::mask_inplace(mb, d.key);
// send header and payload
d.state = d.remain > 0 ? 2 : 99;
assert(! d.ws.wr_block_);
BOOST_ASSERT(! d.ws.wr_block_);
d.ws.wr_block_ = &d;
boost::asio::async_write(d.ws.stream_,
buffer_cat(d.fh_buf.data(),
@@ -237,7 +237,7 @@ operator()(error_code ec, bool again)
// send payload
if(d.remain == 0)
d.state = 99;
assert(d.ws.wr_block_ == &d);
BOOST_ASSERT(d.ws.wr_block_ == &d);
boost::asio::async_write(
d.ws.stream_, mb, std::move(*this));
return;
+1 -1
View File
@@ -12,8 +12,8 @@
#include <beast/core/prepare_buffers.hpp>
#include <beast/core/handler_alloc.hpp>
#include <beast/websocket/detail/frame.hpp>
#include <boost/assert.hpp>
#include <algorithm>
#include <cassert>
#include <memory>
namespace beast {