8template <
typename IntegralT>
17 std::string
name()
const override
23 void rand_bytes(
unsigned char *buf,
size_t size)
override
26 throw s_min_error(
"rand_bytes failed");
33 if (size <
sizeof(IntegralT))
35 IntegralT *int_ptr =
reinterpret_cast<IntegralT *
>(buf);
36 *int_ptr = std::numeric_limits<IntegralT>::min();
42 return rand_get_positive<IntegralT>();
46template <
typename IntegralT>
53 EXPECT_EQ(result, 0) <<
"fails for \"" << test_name <<
"\" test";
56#define RANDAPI_SIGNED_MIN_TEST(test) \
59 randapi_signed_min_test<test>(#test); \
63TEST(misc, randapi_signed_min)
bool rand_bytes_noexcept(unsigned char *buf, size_t size) override
Fill a buffer with random bytes without throwing exceptions.
std::string name() const override
Get the name of the random number generation algorithm.
OPENVPN_EXCEPTION(s_min_error)
void rand_bytes(unsigned char *buf, size_t size) override
Fill a buffer with random bytes.
Abstract base class for pseudo random number generators.
Implementation of the base classes for random number generators.
TEST(misc, randapi_signed_min)
void randapi_signed_min_test(const std::string &test_name)
#define RANDAPI_SIGNED_MIN_TEST(test)