]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/test/beast/core/_detail_varint.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / beast / test / beast / core / _detail_varint.cpp
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7
8 // Test that header file is self-contained.
9 #include <boost/beast/core/detail/varint.hpp>
10
11 #include <boost/beast/_experimental/unit_test/suite.hpp>
12
13 namespace boost {
14 namespace beast {
15 namespace detail {
16
17 class varint_test : public beast::unit_test::suite
18 {
19 public:
20 void
21 testVarint()
22 {
23 std::size_t n0 = 0;
24 std::size_t n1 = 1;
25 for(;;)
26 {
27 char buf[16];
28 BOOST_ASSERT(sizeof(buf) >= varint_size(n0));
29 auto it = &buf[0];
30 varint_write(it, n0);
31 it = &buf[0];
32 auto n = varint_read(it);
33 BEAST_EXPECT(n == n0);
34 n = n0 + n1;
35 if(n < n1)
36 break;
37 n0 = n1;
38 n1 = n;
39 }
40 }
41
42 void
43 run()
44 {
45 testVarint();
46 }
47 };
48
49 BEAST_DEFINE_TESTSUITE(beast,core,varint);
50
51 } // detail
52 } // beast
53 } // boost