random/test/test_uniform_real_distribution.cpp
2014-03-13 14:50:17 -07:00

49 lines
1.4 KiB
C++

/* test_uniform_real_distribution.cpp
*
* Copyright Steven Watanabe 2011
* 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)
*
* $Id$
*
*/
#include <boost/random/uniform_real_distribution.hpp>
#include <limits>
#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_real_distribution<>
#define BOOST_RANDOM_ARG1 a
#define BOOST_RANDOM_ARG2 b
#define BOOST_RANDOM_ARG1_DEFAULT 0.0
#define BOOST_RANDOM_ARG2_DEFAULT 1.0
#define BOOST_RANDOM_ARG1_VALUE -0.5
#define BOOST_RANDOM_ARG2_VALUE 1.5
#define BOOST_RANDOM_DIST0_MIN 0.0
#define BOOST_RANDOM_DIST0_MAX 1.0
#define BOOST_RANDOM_DIST1_MIN -0.5
#define BOOST_RANDOM_DIST1_MAX 1.0
#define BOOST_RANDOM_DIST2_MIN -0.5
#define BOOST_RANDOM_DIST2_MAX 1.5
#define BOOST_RANDOM_TEST1_PARAMS (-1.0, 0.0)
#define BOOST_RANDOM_TEST1_MIN -1.0
#define BOOST_RANDOM_TEST1_MAX 0.0
#define BOOST_RANDOM_TEST2_PARAMS
#define BOOST_RANDOM_TEST2_MIN 0.0
#define BOOST_RANDOM_TEST2_MAX 1.0
#include "test_distribution.ipp"
BOOST_AUTO_TEST_CASE(test_dbl_min_max) {
boost::random::minstd_rand rng;
double min = -(std::numeric_limits<double>::max)();
double max = (std::numeric_limits<double>::max)();
boost::random::uniform_real_distribution<double> dist(min, max);
double val = dist(rng);
BOOST_CHECK_GE(val, min);
BOOST_CHECK_LE(val, max);
}