Files
boost_beast/test/beast/websocket/_detail_prng.cpp
Damian Jarek 86176786c3 Expand CI matrix using Azure Pipelines:
* Allow setting a seed in websocket prng to workaround a valgrind bug
  in Xenial.
* Coverage collection in Azp.
* Fixup blacklists to avoid zlib bugs.
* Use native b2 features for sanitizers and valgrind.
* Expanded Windows build matrix.
* Add additional clang (with libc++) builds.

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
2019-05-19 22:32:44 +02:00

80 lines
1.9 KiB
C++

//
// Copyright (c) 2016-2019 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
//
// Test that header file is self-contained.
#include <boost/beast/websocket/detail/prng.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
namespace boost {
namespace beast {
namespace websocket {
namespace detail {
#ifdef BOOST_BEAST_TEST_STATIC_PRNG_SEED
auto prng_init = []()
{
// Workaround for https://bugs.launchpad.net/ubuntu/+source/valgrind/+bug/1501545
std::seed_seq seq{{0xDEAD, 0xBEEF}};
detail::prng_seed(&seq);
return 0;
}();
#endif // BOOST_BEAST_TEST_STATIC_PRNG_SEED
class prng_test
: public beast::unit_test::suite
{
public:
#if 0
char const* name() const noexcept //override
{
return "boost.beast.websocket.detail.prng";
}
#endif
template <class F>
void
testPrng(F const& f)
{
{
auto v = f()();
BEAST_EXPECT(
v >= (prng::ref::min)() &&
v <= (prng::ref::max)());
}
{
auto v = f()();
BEAST_EXPECT(
v >= (prng::ref::min)() &&
v <= (prng::ref::max)());
}
}
void
run() override
{
testPrng([]{ return make_prng(true); });
testPrng([]{ return make_prng(false); });
testPrng([]{ return make_prng_no_tls(true); });
testPrng([]{ return make_prng_no_tls(false); });
#ifndef BOOST_NO_CXX11_THREAD_LOCAL
testPrng([]{ return make_prng_tls(true); });
testPrng([]{ return make_prng_tls(false); });
#endif
}
};
//static prng_test t;
BEAST_DEFINE_TESTSUITE(beast,websocket,prng);
} // detail
} // websocket
} // beast
} // boost