Files
boost_beast/test/beast/core/detail/varint.cpp
T

54 lines
1.1 KiB
C++
Raw Normal View History

2017-07-12 18:06:36 -07:00
//
2017-07-24 09:42:36 -07:00
// Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
2017-07-12 18:06:36 -07:00
//
// 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.
2017-07-20 13:40:34 -07:00
#include <boost/beast/core/detail/varint.hpp>
2017-07-12 18:06:36 -07:00
2017-07-20 13:40:34 -07:00
#include <boost/beast/unit_test/suite.hpp>
2017-07-12 18:06:36 -07:00
2017-07-20 13:40:34 -07:00
namespace boost {
2017-07-12 18:06:36 -07:00
namespace beast {
2017-07-20 13:40:34 -07:00
namespace detail {
2017-07-12 18:06:36 -07:00
class varint_test : public beast::unit_test::suite
{
public:
void
testVarint()
{
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);
2017-07-25 12:35:54 -07:00
BEAST_EXPECT(n == n0);
2017-07-12 18:06:36 -07:00
n = n0 + n1;
if(n < n1)
break;
n0 = n1;
n1 = n;
}
}
void
run()
{
testVarint();
}
};
2017-08-01 17:01:57 -07:00
BEAST_DEFINE_TESTSUITE(beast,core,varint);
2017-07-12 18:06:36 -07:00
2017-07-20 13:40:34 -07:00
} // detail
2017-07-12 18:06:36 -07:00
} // beast
2017-07-20 13:40:34 -07:00
} // boost