|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65093 - in trunk: boost/random libs/random/test
From: steven_at_[hidden]
Date: 2010-08-29 00:03:05
Author: steven_watanabe
Date: 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
New Revision: 65093
URL: http://svn.boost.org/trac/boost/changeset/65093
Log:
Refactor tests
Added:
trunk/libs/random/test/test_distribution.ipp
- copied, changed from r65088, /trunk/libs/random/test/test_binomial_distribution.cpp
Text files modified:
trunk/boost/random/gamma_distribution.hpp | 2
trunk/libs/random/test/test_binomial_distribution.cpp | 142 +++++--------------------------
trunk/libs/random/test/test_distribution.ipp | 178 ++++++++++++++++++++++++---------------
trunk/libs/random/test/test_extreme_value_distribution.cpp | 136 ++++-------------------------
trunk/libs/random/test/test_gamma_distribution.cpp | 141 +++++--------------------------
trunk/libs/random/test/test_poisson_distribution.cpp | 109 ++++--------------------
trunk/libs/random/test/test_weibull_distribution.cpp | 140 ++++--------------------------
7 files changed, 221 insertions(+), 627 deletions(-)
Modified: trunk/boost/random/gamma_distribution.hpp
==============================================================================
--- trunk/boost/random/gamma_distribution.hpp (original)
+++ trunk/boost/random/gamma_distribution.hpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -134,7 +134,7 @@
RealType min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
/* Returns the largest value that the distribution can produce. */
RealType max BOOST_PREVENT_MACRO_SUBSTITUTION () const
- { return (std::numeric_limits<RealType>::max)(); }
+ { return (std::numeric_limits<RealType>::infinity)(); }
/** Returns the parameters of the distribution. */
param_type param() const { return param_type(_alpha, _beta); }
Modified: trunk/libs/random/test/test_binomial_distribution.cpp
==============================================================================
--- trunk/libs/random/test/test_binomial_distribution.cpp (original)
+++ trunk/libs/random/test/test_binomial_distribution.cpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -10,124 +10,28 @@
*/
#include <boost/random/binomial_distribution.hpp>
-#include <boost/random/linear_congruential.hpp>
-#include <sstream>
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
+#define BOOST_RANDOM_DISTRIBUTION boost::random::binomial_distribution<>
+#define BOOST_RANDOM_ARG1 t
+#define BOOST_RANDOM_ARG2 p
+#define BOOST_RANDOM_ARG1_DEFAULT 1
+#define BOOST_RANDOM_ARG2_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_VALUE 10
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 1
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX 10
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX 10
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 1
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 0.25)
+#define BOOST_RANDOM_TEST2_MIN 0
+#define BOOST_RANDOM_TEST2_MAX 10
-BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::binomial_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.t(), 1);
- BOOST_CHECK_EQUAL(dist.p(), 0.5);
- boost::random::binomial_distribution<> dist_one(10);
- BOOST_CHECK_EQUAL(dist_one.t(), 10);
- BOOST_CHECK_EQUAL(dist_one.p(), 0.5);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- BOOST_CHECK_EQUAL(dist_two.t(), 10);
- BOOST_CHECK_EQUAL(dist_two.p(), 0.25);
- boost::random::binomial_distribution<> copy(dist);
- BOOST_CHECK_EQUAL(dist, copy);
- boost::random::binomial_distribution<> copy_one(dist_one);
- BOOST_CHECK_EQUAL(dist_one, copy_one);
- boost::random::binomial_distribution<> copy_two(dist_two);
- BOOST_CHECK_EQUAL(dist_two, copy_two);
-}
-
-BOOST_AUTO_TEST_CASE(test_copy_constructor) {
- boost::random::binomial_distribution<> dist(10, 0.25);
-}
-
-BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::binomial_distribution<> dist(10, 0.25);
- boost::random::binomial_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.t(), 10);
- BOOST_CHECK_EQUAL(param.p(), 0.25);
- boost::random::binomial_distribution<> copy1(param);
- BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::binomial_distribution<> copy2;
- copy2.param(param);
- BOOST_CHECK_EQUAL(dist, copy2);
-
- boost::random::binomial_distribution<>::param_type param_copy = param;
- BOOST_CHECK_EQUAL(param, param_copy);
- BOOST_CHECK(param == param_copy);
- BOOST_CHECK(!(param != param_copy));
- boost::random::binomial_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.t(), 1);
- BOOST_CHECK_EQUAL(param_default.p(), 0.5);
- BOOST_CHECK(param != param_default);
- BOOST_CHECK(!(param == param_default));
- boost::random::binomial_distribution<>::param_type param_one(10);
- BOOST_CHECK_EQUAL(param_one.t(), 10);
- BOOST_CHECK_EQUAL(param_one.p(), 0.5);
- BOOST_CHECK(param != param_one);
- BOOST_CHECK(!(param == param_one));
- BOOST_CHECK(param_default != param_one);
- BOOST_CHECK(!(param_default == param_one));
- boost::random::binomial_distribution<>::param_type param_two(10, 0.25);
- BOOST_CHECK_EQUAL(param_two.t(), 10);
- BOOST_CHECK_EQUAL(param_two.p(), 0.25);
-}
-
-BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::binomial_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), 0);
- BOOST_CHECK_EQUAL((dist.max)(), 1);
- boost::random::binomial_distribution<> dist_one(10);
- BOOST_CHECK_EQUAL((dist_one.min)(), 0);
- BOOST_CHECK_EQUAL((dist_one.max)(), 10);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- BOOST_CHECK_EQUAL((dist_two.min)(), 0);
- BOOST_CHECK_EQUAL((dist_two.max)(), 10);
-}
-
-BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::binomial_distribution<> dist;
- boost::random::binomial_distribution<> dist_copy(dist);
- boost::random::binomial_distribution<> dist_one(10);
- boost::random::binomial_distribution<> dist_one_copy(dist_one);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- boost::random::binomial_distribution<> dist_two_copy(dist_two);
- BOOST_CHECK(dist == dist_copy);
- BOOST_CHECK(!(dist != dist_copy));
- BOOST_CHECK(dist_one == dist_one_copy);
- BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist_two == dist_two_copy);
- BOOST_CHECK(!(dist_two != dist_two_copy));
- BOOST_CHECK(dist != dist_one);
- BOOST_CHECK(!(dist == dist_one));
- BOOST_CHECK(dist != dist_two);
- BOOST_CHECK(!(dist == dist_two));
- BOOST_CHECK(dist_one != dist_two);
- BOOST_CHECK(!(dist_one == dist_two));
-}
-
-BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::binomial_distribution<> dist(10, 0.25);
- std::stringstream stream;
- stream << dist;
- boost::random::binomial_distribution<> restored_dist;
- stream >> restored_dist;
- BOOST_CHECK_EQUAL(dist, restored_dist);
-}
-
-BOOST_AUTO_TEST_CASE(test_generation) {
- boost::minstd_rand0 gen;
- boost::random::binomial_distribution<> dist;
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- for(int i = 0; i < 10; ++i) {
- int value = dist(gen);
- BOOST_CHECK_GE(value, (dist.min)());
- BOOST_CHECK_LE(value, (dist.max)());
- int value_two = dist_two(gen);
- BOOST_CHECK_GE(value_two, (dist_two.min)());
- BOOST_CHECK_LE(value_two, (dist_two.max)());
- int value_param = dist_two(gen, dist.param());
- BOOST_CHECK_GE(value_param, (dist.min)());
- BOOST_CHECK_LE(value_param, (dist.max)());
- int value_two_param = dist(gen, dist_two.param());
- BOOST_CHECK_GE(value_two_param, (dist_two.min)());
- BOOST_CHECK_LE(value_two_param, (dist_two.max)());
- }
-}
+#include "test_distribution.ipp"
Copied: trunk/libs/random/test/test_distribution.ipp (from r65088, /trunk/libs/random/test/test_binomial_distribution.cpp)
==============================================================================
--- /trunk/libs/random/test/test_binomial_distribution.cpp (original)
+++ trunk/libs/random/test/test_distribution.ipp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -1,4 +1,4 @@
-/* test_binomial_distribution.cpp
+/* test_distribution.ipp
*
* Copyright Steven Watanabe 2010
* Distributed under the Boost Software License, Version 1.0. (See
@@ -9,7 +9,6 @@
*
*/
-#include <boost/random/binomial_distribution.hpp>
#include <boost/random/linear_congruential.hpp>
#include <sstream>
@@ -17,117 +16,162 @@
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::binomial_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.t(), 1);
- BOOST_CHECK_EQUAL(dist.p(), 0.5);
- boost::random::binomial_distribution<> dist_one(10);
- BOOST_CHECK_EQUAL(dist_one.t(), 10);
- BOOST_CHECK_EQUAL(dist_one.p(), 0.5);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- BOOST_CHECK_EQUAL(dist_two.t(), 10);
- BOOST_CHECK_EQUAL(dist_two.p(), 0.25);
- boost::random::binomial_distribution<> copy(dist);
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_CHECK_EQUAL(dist.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_DEFAULT);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(dist.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(dist_one.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(dist_one.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(dist_two.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(dist_two.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION copy(dist);
BOOST_CHECK_EQUAL(dist, copy);
- boost::random::binomial_distribution<> copy_one(dist_one);
+ BOOST_RANDOM_DISTRIBUTION copy_one(dist_one);
BOOST_CHECK_EQUAL(dist_one, copy_one);
- boost::random::binomial_distribution<> copy_two(dist_two);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION copy_two(dist_two);
BOOST_CHECK_EQUAL(dist_two, copy_two);
-}
-
-BOOST_AUTO_TEST_CASE(test_copy_constructor) {
- boost::random::binomial_distribution<> dist(10, 0.25);
+#endif
}
BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::binomial_distribution<> dist(10, 0.25);
- boost::random::binomial_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.t(), 10);
- BOOST_CHECK_EQUAL(param.p(), 0.25);
- boost::random::binomial_distribution<> copy1(param);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+#else
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION::param_type param = dist.param();
+ BOOST_CHECK_EQUAL(param.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION copy1(param);
BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::binomial_distribution<> copy2;
+ BOOST_RANDOM_DISTRIBUTION copy2;
copy2.param(param);
BOOST_CHECK_EQUAL(dist, copy2);
- boost::random::binomial_distribution<>::param_type param_copy = param;
+ BOOST_RANDOM_DISTRIBUTION::param_type param_copy = param;
BOOST_CHECK_EQUAL(param, param_copy);
BOOST_CHECK(param == param_copy);
BOOST_CHECK(!(param != param_copy));
- boost::random::binomial_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.t(), 1);
- BOOST_CHECK_EQUAL(param_default.p(), 0.5);
+ BOOST_RANDOM_DISTRIBUTION::param_type param_default;
+ BOOST_CHECK_EQUAL(param_default.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_DEFAULT);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param_default.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
BOOST_CHECK(param != param_default);
BOOST_CHECK(!(param == param_default));
- boost::random::binomial_distribution<>::param_type param_one(10);
- BOOST_CHECK_EQUAL(param_one.t(), 10);
- BOOST_CHECK_EQUAL(param_one.p(), 0.5);
+ BOOST_RANDOM_DISTRIBUTION::param_type param_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(param_one.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param_one.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG2
BOOST_CHECK(param != param_one);
BOOST_CHECK(!(param == param_one));
+#endif
BOOST_CHECK(param_default != param_one);
BOOST_CHECK(!(param_default == param_one));
- boost::random::binomial_distribution<>::param_type param_two(10, 0.25);
- BOOST_CHECK_EQUAL(param_two.t(), 10);
- BOOST_CHECK_EQUAL(param_two.p(), 0.25);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION::param_type param_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(param_two.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(param_two.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#endif
}
BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::binomial_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), 0);
- BOOST_CHECK_EQUAL((dist.max)(), 1);
- boost::random::binomial_distribution<> dist_one(10);
- BOOST_CHECK_EQUAL((dist_one.min)(), 0);
- BOOST_CHECK_EQUAL((dist_one.max)(), 10);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- BOOST_CHECK_EQUAL((dist_two.min)(), 0);
- BOOST_CHECK_EQUAL((dist_two.max)(), 10);
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_CHECK_EQUAL((dist.min)(), BOOST_RANDOM_DIST0_MIN);
+ BOOST_CHECK_EQUAL((dist.max)(), BOOST_RANDOM_DIST0_MAX);
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL((dist_one.min)(), BOOST_RANDOM_DIST1_MIN);
+ BOOST_CHECK_EQUAL((dist_one.max)(), BOOST_RANDOM_DIST1_MAX);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL((dist_two.min)(), BOOST_RANDOM_DIST2_MIN);
+ BOOST_CHECK_EQUAL((dist_two.max)(), BOOST_RANDOM_DIST2_MAX);
+#endif
}
BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::binomial_distribution<> dist;
- boost::random::binomial_distribution<> dist_copy(dist);
- boost::random::binomial_distribution<> dist_one(10);
- boost::random::binomial_distribution<> dist_one_copy(dist_one);
- boost::random::binomial_distribution<> dist_two(10, 0.25);
- boost::random::binomial_distribution<> dist_two_copy(dist_two);
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_RANDOM_DISTRIBUTION dist_copy(dist);
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_RANDOM_DISTRIBUTION dist_one_copy(dist_one);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_RANDOM_DISTRIBUTION dist_two_copy(dist_two);
+#endif
BOOST_CHECK(dist == dist_copy);
BOOST_CHECK(!(dist != dist_copy));
BOOST_CHECK(dist_one == dist_one_copy);
BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist_two == dist_two_copy);
- BOOST_CHECK(!(dist_two != dist_two_copy));
BOOST_CHECK(dist != dist_one);
BOOST_CHECK(!(dist == dist_one));
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK(dist_two == dist_two_copy);
+ BOOST_CHECK(!(dist_two != dist_two_copy));
BOOST_CHECK(dist != dist_two);
BOOST_CHECK(!(dist == dist_two));
BOOST_CHECK(dist_one != dist_two);
BOOST_CHECK(!(dist_one == dist_two));
+#endif
}
BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::binomial_distribution<> dist(10, 0.25);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+#else
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE);
+#endif
std::stringstream stream;
stream << dist;
- boost::random::binomial_distribution<> restored_dist;
+ BOOST_RANDOM_DISTRIBUTION restored_dist;
stream >> restored_dist;
BOOST_CHECK_EQUAL(dist, restored_dist);
}
BOOST_AUTO_TEST_CASE(test_generation) {
boost::minstd_rand0 gen;
- boost::random::binomial_distribution<> dist;
- boost::random::binomial_distribution<> dist_two(10, 0.25);
+ BOOST_RANDOM_DISTRIBUTION dist BOOST_RANDOM_TEST1_PARAMS;
+ BOOST_RANDOM_DISTRIBUTION dist_two BOOST_RANDOM_TEST2_PARAMS;
+ typedef BOOST_RANDOM_DISTRIBUTION::result_type result_type;
for(int i = 0; i < 10; ++i) {
- int value = dist(gen);
- BOOST_CHECK_GE(value, (dist.min)());
- BOOST_CHECK_LE(value, (dist.max)());
- int value_two = dist_two(gen);
- BOOST_CHECK_GE(value_two, (dist_two.min)());
- BOOST_CHECK_LE(value_two, (dist_two.max)());
- int value_param = dist_two(gen, dist.param());
- BOOST_CHECK_GE(value_param, (dist.min)());
- BOOST_CHECK_LE(value_param, (dist.max)());
- int value_two_param = dist(gen, dist_two.param());
- BOOST_CHECK_GE(value_two_param, (dist_two.min)());
- BOOST_CHECK_LE(value_two_param, (dist_two.max)());
+ result_type value = dist(gen);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two = dist_two(gen);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two, BOOST_RANDOM_TEST2_MAX);
+#endif
+ result_type value_param = dist_two(gen, dist.param());
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value_param, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value_param, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two_param = dist(gen, dist_two.param());
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two_param, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two_param, BOOST_RANDOM_TEST2_MAX);
+#endif
}
}
Modified: trunk/libs/random/test/test_extreme_value_distribution.cpp
==============================================================================
--- trunk/libs/random/test/test_extreme_value_distribution.cpp (original)
+++ trunk/libs/random/test/test_extreme_value_distribution.cpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -10,119 +10,27 @@
*/
#include <boost/random/extreme_value_distribution.hpp>
-#include <boost/random/linear_congruential.hpp>
-#include <sstream>
+#include <limits>
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
+#define BOOST_RANDOM_DISTRIBUTION boost::random::extreme_value_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
-BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::extreme_value_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.a(), 1.0);
- BOOST_CHECK_EQUAL(dist.b(), 1.0);
- boost::random::extreme_value_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL(dist_one.a(), 7.5);
- BOOST_CHECK_EQUAL(dist_one.b(), 1.0);
- boost::random::extreme_value_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(dist_two.a(), 7.5);
- BOOST_CHECK_EQUAL(dist_two.b(), 0.25);
- boost::random::extreme_value_distribution<> copy(dist);
- BOOST_CHECK_EQUAL(dist, copy);
- boost::random::extreme_value_distribution<> copy_one(dist_one);
- BOOST_CHECK_EQUAL(dist_one, copy_one);
- boost::random::extreme_value_distribution<> copy_two(dist_two);
- BOOST_CHECK_EQUAL(dist_two, copy_two);
-}
-
-BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::extreme_value_distribution<> dist(7.5, 0.25);
- boost::random::extreme_value_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.a(), 7.5);
- BOOST_CHECK_EQUAL(param.b(), 0.25);
- boost::random::extreme_value_distribution<> copy1(param);
- BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::extreme_value_distribution<> copy2;
- copy2.param(param);
- BOOST_CHECK_EQUAL(dist, copy2);
-
- boost::random::extreme_value_distribution<>::param_type param_copy = param;
- BOOST_CHECK_EQUAL(param, param_copy);
- BOOST_CHECK(param == param_copy);
- BOOST_CHECK(!(param != param_copy));
- boost::random::extreme_value_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.a(), 1.0);
- BOOST_CHECK_EQUAL(param_default.b(), 1.0);
- BOOST_CHECK(param != param_default);
- BOOST_CHECK(!(param == param_default));
- boost::random::extreme_value_distribution<>::param_type param_one(7.5);
- BOOST_CHECK_EQUAL(param_one.a(), 7.5);
- BOOST_CHECK_EQUAL(param_one.b(), 1.0);
- BOOST_CHECK(param != param_one);
- BOOST_CHECK(!(param == param_one));
- BOOST_CHECK(param_default != param_one);
- BOOST_CHECK(!(param_default == param_one));
- boost::random::extreme_value_distribution<>::param_type param_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(param_two.a(), 7.5);
- BOOST_CHECK_EQUAL(param_two.b(), 0.25);
-}
-
-BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::extreme_value_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), -(std::numeric_limits<double>::infinity)());
- BOOST_CHECK_EQUAL((dist.max)(), (std::numeric_limits<double>::infinity)());
- boost::random::extreme_value_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL((dist_one.min)(), -(std::numeric_limits<double>::infinity)());
- BOOST_CHECK_EQUAL((dist_one.max)(), (std::numeric_limits<double>::infinity)());
- boost::random::extreme_value_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL((dist_two.min)(), -(std::numeric_limits<double>::infinity)());
- BOOST_CHECK_EQUAL((dist_two.max)(), (std::numeric_limits<double>::infinity)());
-}
-
-BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::extreme_value_distribution<> dist;
- boost::random::extreme_value_distribution<> dist_copy(dist);
- boost::random::extreme_value_distribution<> dist_one(7.5);
- boost::random::extreme_value_distribution<> dist_one_copy(dist_one);
- boost::random::extreme_value_distribution<> dist_two(7.5, 0.25);
- boost::random::extreme_value_distribution<> dist_two_copy(dist_two);
- BOOST_CHECK(dist == dist_copy);
- BOOST_CHECK(!(dist != dist_copy));
- BOOST_CHECK(dist_one == dist_one_copy);
- BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist_two == dist_two_copy);
- BOOST_CHECK(!(dist_two != dist_two_copy));
- BOOST_CHECK(dist != dist_one);
- BOOST_CHECK(!(dist == dist_one));
- BOOST_CHECK(dist != dist_two);
- BOOST_CHECK(!(dist == dist_two));
- BOOST_CHECK(dist_one != dist_two);
- BOOST_CHECK(!(dist_one == dist_two));
-}
-
-BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::extreme_value_distribution<> dist(7.5, 0.25);
- std::stringstream stream;
- stream << dist;
- boost::random::extreme_value_distribution<> restored_dist;
- stream >> restored_dist;
- BOOST_CHECK_EQUAL(dist, restored_dist);
-}
-
-BOOST_AUTO_TEST_CASE(test_generation) {
- boost::minstd_rand0 gen;
- boost::random::extreme_value_distribution<> dist(-100.0);
- boost::random::extreme_value_distribution<> dist_two(100.0);
- for(int i = 0; i < 10; ++i) {
- // This test is not guaranteed to work, since
- // a extreme value distribution with a large location
- // parameter can produce small values and vice versa
- double value = dist(gen);
- BOOST_CHECK_LE(value, 0.0);
- double value_two = dist_two(gen);
- BOOST_CHECK_GE(value_two, 0.0);
- double value_param = dist_two(gen, dist.param());
- BOOST_CHECK_LE(value_param, 0.0);
- double value_two_param = dist(gen, dist_two.param());
- BOOST_CHECK_GE(value_two_param, 0.0);
- }
-}
+#define BOOST_RANDOM_TEST1_PARAMS (-100.0)
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+#define BOOST_RANDOM_TEST2_MIN 0
+
+#include "test_distribution.ipp"
Modified: trunk/libs/random/test/test_gamma_distribution.cpp
==============================================================================
--- trunk/libs/random/test/test_gamma_distribution.cpp (original)
+++ trunk/libs/random/test/test_gamma_distribution.cpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -10,123 +10,28 @@
*/
#include <boost/random/gamma_distribution.hpp>
-#include <boost/random/linear_congruential.hpp>
-#include <sstream>
+#include <limits>
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
+#define BOOST_RANDOM_DISTRIBUTION boost::random::gamma_distribution<>
+#define BOOST_RANDOM_ARG1 alpha
+#define BOOST_RANDOM_ARG2 beta
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
-BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::gamma_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.alpha(), 1.0);
- BOOST_CHECK_EQUAL(dist.beta(), 1.0);
- boost::random::gamma_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL(dist_one.alpha(), 7.5);
- BOOST_CHECK_EQUAL(dist_one.beta(), 1.0);
- boost::random::gamma_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(dist_two.alpha(), 7.5);
- BOOST_CHECK_EQUAL(dist_two.beta(), 0.25);
- boost::random::gamma_distribution<> copy(dist);
- BOOST_CHECK_EQUAL(dist, copy);
- boost::random::gamma_distribution<> copy_one(dist_one);
- BOOST_CHECK_EQUAL(dist_one, copy_one);
- boost::random::gamma_distribution<> copy_two(dist_two);
- BOOST_CHECK_EQUAL(dist_two, copy_two);
-}
-
-BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::gamma_distribution<> dist(7.5, 0.25);
- boost::random::gamma_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.alpha(), 7.5);
- BOOST_CHECK_EQUAL(param.beta(), 0.25);
- boost::random::gamma_distribution<> copy1(param);
- BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::gamma_distribution<> copy2;
- copy2.param(param);
- BOOST_CHECK_EQUAL(dist, copy2);
-
- boost::random::gamma_distribution<>::param_type param_copy = param;
- BOOST_CHECK_EQUAL(param, param_copy);
- BOOST_CHECK(param == param_copy);
- BOOST_CHECK(!(param != param_copy));
- boost::random::gamma_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.alpha(), 1.0);
- BOOST_CHECK_EQUAL(param_default.beta(), 1.0);
- BOOST_CHECK(param != param_default);
- BOOST_CHECK(!(param == param_default));
- boost::random::gamma_distribution<>::param_type param_one(7.5);
- BOOST_CHECK_EQUAL(param_one.alpha(), 7.5);
- BOOST_CHECK_EQUAL(param_one.beta(), 1.0);
- BOOST_CHECK(param != param_one);
- BOOST_CHECK(!(param == param_one));
- BOOST_CHECK(param_default != param_one);
- BOOST_CHECK(!(param_default == param_one));
- boost::random::gamma_distribution<>::param_type param_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(param_two.alpha(), 7.5);
- BOOST_CHECK_EQUAL(param_two.beta(), 0.25);
-}
-
-BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::gamma_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), 0);
- BOOST_CHECK_EQUAL((dist.max)(), (std::numeric_limits<double>::max)());
- boost::random::gamma_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL((dist_one.min)(), 0);
- BOOST_CHECK_EQUAL((dist_one.max)(), (std::numeric_limits<double>::max)());
- boost::random::gamma_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL((dist_two.min)(), 0);
- BOOST_CHECK_EQUAL((dist_two.max)(), (std::numeric_limits<double>::max)());
-}
-
-BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::gamma_distribution<> dist;
- boost::random::gamma_distribution<> dist_copy(dist);
- boost::random::gamma_distribution<> dist_one(7.5);
- boost::random::gamma_distribution<> dist_one_copy(dist_one);
- boost::random::gamma_distribution<> dist_two(7.5, 0.25);
- boost::random::gamma_distribution<> dist_two_copy(dist_two);
- BOOST_CHECK(dist == dist_copy);
- BOOST_CHECK(!(dist != dist_copy));
- BOOST_CHECK(dist_one == dist_one_copy);
- BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist_two == dist_two_copy);
- BOOST_CHECK(!(dist_two != dist_two_copy));
- BOOST_CHECK(dist != dist_one);
- BOOST_CHECK(!(dist == dist_one));
- BOOST_CHECK(dist != dist_two);
- BOOST_CHECK(!(dist == dist_two));
- BOOST_CHECK(dist_one != dist_two);
- BOOST_CHECK(!(dist_one == dist_two));
-}
-
-BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::gamma_distribution<> dist(7.5, 0.25);
- std::stringstream stream;
- stream << dist;
- boost::random::gamma_distribution<> restored_dist;
- stream >> restored_dist;
- BOOST_CHECK_EQUAL(dist, restored_dist);
-}
-
-BOOST_AUTO_TEST_CASE(test_generation) {
- boost::minstd_rand0 gen;
- boost::random::gamma_distribution<> dist;
- boost::random::gamma_distribution<> dist_two(1.0, 1000000.0);
- for(int i = 0; i < 10; ++i) {
- // This test is not guaranteed to work, since
- // a gamma distribution with a large scale parameter
- // can produce small values and a distribution with
- // a small scale can produce large values, but the
- // chances of failure are small.
- double value = dist(gen);
- BOOST_CHECK_GE(value, 0.0);
- BOOST_CHECK_LE(value, 100.0);
- double value_two = dist_two(gen);
- BOOST_CHECK_GE(value_two, 100.0);
- double value_param = dist_two(gen, dist.param());
- BOOST_CHECK_GE(value_param, 0);
- BOOST_CHECK_LE(value_param, 100.0);
- double value_two_param = dist(gen, dist_two.param());
- BOOST_CHECK_GE(value_two_param, 100.0);
- }
-}
+#define BOOST_RANDOM_TEST2_PARAMS (1.0, 1000000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
+
+#include "test_distribution.ipp"
Modified: trunk/libs/random/test/test_poisson_distribution.cpp
==============================================================================
--- trunk/libs/random/test/test_poisson_distribution.cpp (original)
+++ trunk/libs/random/test/test_poisson_distribution.cpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -10,95 +10,24 @@
*/
#include <boost/random/poisson_distribution.hpp>
-#include <boost/random/linear_congruential.hpp>
-#include <sstream>
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
+#include <limits>
-BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::poisson_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.mean(), 1.0);
- boost::random::poisson_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL(dist_one.mean(), 7.5);
- boost::random::poisson_distribution<> copy(dist);
- BOOST_CHECK_EQUAL(dist, copy);
- boost::random::poisson_distribution<> copy_one(dist_one);
- BOOST_CHECK_EQUAL(dist_one, copy_one);
-}
-
-BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::poisson_distribution<> dist(7.5);
- boost::random::poisson_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.mean(), 7.5);
- boost::random::poisson_distribution<> copy1(param);
- BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::poisson_distribution<> copy2;
- copy2.param(param);
- BOOST_CHECK_EQUAL(dist, copy2);
-
- boost::random::poisson_distribution<>::param_type param_copy = param;
- BOOST_CHECK_EQUAL(param, param_copy);
- BOOST_CHECK(param == param_copy);
- BOOST_CHECK(!(param != param_copy));
- boost::random::poisson_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.mean(), 1.0);
- BOOST_CHECK(param != param_default);
- BOOST_CHECK(!(param == param_default));
- boost::random::poisson_distribution<>::param_type param_one(7.5);
- BOOST_CHECK_EQUAL(param_one.mean(), 7.5);
- BOOST_CHECK(param_default != param_one);
- BOOST_CHECK(!(param_default == param_one));
-}
-
-BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::poisson_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), 0);
- BOOST_CHECK_EQUAL((dist.max)(), (std::numeric_limits<int>::max)());
- boost::random::poisson_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL((dist_one.min)(), 0);
- BOOST_CHECK_EQUAL((dist_one.max)(), (std::numeric_limits<int>::max)());
-}
-
-BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::poisson_distribution<> dist;
- boost::random::poisson_distribution<> dist_copy(dist);
- boost::random::poisson_distribution<> dist_one(7.5);
- boost::random::poisson_distribution<> dist_one_copy(dist_one);
- BOOST_CHECK(dist == dist_copy);
- BOOST_CHECK(!(dist != dist_copy));
- BOOST_CHECK(dist_one == dist_one_copy);
- BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist != dist_one);
- BOOST_CHECK(!(dist == dist_one));
-}
-
-BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::poisson_distribution<> dist(7.5);
- std::stringstream stream;
- stream << dist;
- boost::random::poisson_distribution<> restored_dist;
- stream >> restored_dist;
- BOOST_CHECK_EQUAL(dist, restored_dist);
-}
-
-BOOST_AUTO_TEST_CASE(test_generation) {
- boost::minstd_rand0 gen;
- boost::random::poisson_distribution<> dist;
- boost::random::poisson_distribution<> dist_1000(1000);
- for(int i = 0; i < 10; ++i) {
- // Basic sanity checks. Technically these tests are incorrect,
- // since the range of a poisson_distribution is [0, inf), but
- // the probability that there's an error is very small.
- int value = dist(gen);
- BOOST_CHECK_GE(value, 0);
- BOOST_CHECK_LE(value, 10);
- int value_two = dist_1000(gen);
- BOOST_CHECK_GE(value_two, 10);
- int value_param = dist_1000(gen, dist.param());
- BOOST_CHECK_GE(value_param, 0);
- BOOST_CHECK_LE(value_param, 10);
- int value_two_param = dist(gen, dist_1000.param());
- BOOST_CHECK_GE(value_two_param, 10);
- }
-}
+#define BOOST_RANDOM_DISTRIBUTION boost::random::poisson_distribution<>
+#define BOOST_RANDOM_ARG1 mean
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<int>::max)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<int>::max)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 10.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1000.0)
+#define BOOST_RANDOM_TEST2_MIN 10.0
+
+#include "test_distribution.ipp"
Modified: trunk/libs/random/test/test_weibull_distribution.cpp
==============================================================================
--- trunk/libs/random/test/test_weibull_distribution.cpp (original)
+++ trunk/libs/random/test/test_weibull_distribution.cpp 2010-08-29 00:03:02 EDT (Sun, 29 Aug 2010)
@@ -8,125 +8,29 @@
* $Id$
*
*/
-
#include <boost/random/weibull_distribution.hpp>
-#include <boost/random/linear_congruential.hpp>
-#include <sstream>
-
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
-
-BOOST_AUTO_TEST_CASE(test_constructors) {
- boost::random::weibull_distribution<> dist;
- BOOST_CHECK_EQUAL(dist.a(), 1.0);
- BOOST_CHECK_EQUAL(dist.b(), 1.0);
- boost::random::weibull_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL(dist_one.a(), 7.5);
- BOOST_CHECK_EQUAL(dist_one.b(), 1.0);
- boost::random::weibull_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(dist_two.a(), 7.5);
- BOOST_CHECK_EQUAL(dist_two.b(), 0.25);
- boost::random::weibull_distribution<> copy(dist);
- BOOST_CHECK_EQUAL(dist, copy);
- boost::random::weibull_distribution<> copy_one(dist_one);
- BOOST_CHECK_EQUAL(dist_one, copy_one);
- boost::random::weibull_distribution<> copy_two(dist_two);
- BOOST_CHECK_EQUAL(dist_two, copy_two);
-}
-
-BOOST_AUTO_TEST_CASE(test_param) {
- boost::random::weibull_distribution<> dist(7.5, 0.25);
- boost::random::weibull_distribution<>::param_type param = dist.param();
- BOOST_CHECK_EQUAL(param.a(), 7.5);
- BOOST_CHECK_EQUAL(param.b(), 0.25);
- boost::random::weibull_distribution<> copy1(param);
- BOOST_CHECK_EQUAL(dist, copy1);
- boost::random::weibull_distribution<> copy2;
- copy2.param(param);
- BOOST_CHECK_EQUAL(dist, copy2);
-
- boost::random::weibull_distribution<>::param_type param_copy = param;
- BOOST_CHECK_EQUAL(param, param_copy);
- BOOST_CHECK(param == param_copy);
- BOOST_CHECK(!(param != param_copy));
- boost::random::weibull_distribution<>::param_type param_default;
- BOOST_CHECK_EQUAL(param_default.a(), 1.0);
- BOOST_CHECK_EQUAL(param_default.b(), 1.0);
- BOOST_CHECK(param != param_default);
- BOOST_CHECK(!(param == param_default));
- boost::random::weibull_distribution<>::param_type param_one(7.5);
- BOOST_CHECK_EQUAL(param_one.a(), 7.5);
- BOOST_CHECK_EQUAL(param_one.b(), 1.0);
- BOOST_CHECK(param != param_one);
- BOOST_CHECK(!(param == param_one));
- BOOST_CHECK(param_default != param_one);
- BOOST_CHECK(!(param_default == param_one));
- boost::random::weibull_distribution<>::param_type param_two(7.5, 0.25);
- BOOST_CHECK_EQUAL(param_two.a(), 7.5);
- BOOST_CHECK_EQUAL(param_two.b(), 0.25);
-}
-
-BOOST_AUTO_TEST_CASE(test_min_max) {
- boost::random::weibull_distribution<> dist;
- BOOST_CHECK_EQUAL((dist.min)(), 0);
- BOOST_CHECK_EQUAL((dist.max)(), (std::numeric_limits<double>::infinity)());
- boost::random::weibull_distribution<> dist_one(7.5);
- BOOST_CHECK_EQUAL((dist_one.min)(), 0);
- BOOST_CHECK_EQUAL((dist_one.max)(), (std::numeric_limits<double>::infinity)());
- boost::random::weibull_distribution<> dist_two(7.5, 0.25);
- BOOST_CHECK_EQUAL((dist_two.min)(), 0);
- BOOST_CHECK_EQUAL((dist_two.max)(), (std::numeric_limits<double>::infinity)());
-}
+#include <limits>
-BOOST_AUTO_TEST_CASE(test_comparison) {
- boost::random::weibull_distribution<> dist;
- boost::random::weibull_distribution<> dist_copy(dist);
- boost::random::weibull_distribution<> dist_one(7.5);
- boost::random::weibull_distribution<> dist_one_copy(dist_one);
- boost::random::weibull_distribution<> dist_two(7.5, 0.25);
- boost::random::weibull_distribution<> dist_two_copy(dist_two);
- BOOST_CHECK(dist == dist_copy);
- BOOST_CHECK(!(dist != dist_copy));
- BOOST_CHECK(dist_one == dist_one_copy);
- BOOST_CHECK(!(dist_one != dist_one_copy));
- BOOST_CHECK(dist_two == dist_two_copy);
- BOOST_CHECK(!(dist_two != dist_two_copy));
- BOOST_CHECK(dist != dist_one);
- BOOST_CHECK(!(dist == dist_one));
- BOOST_CHECK(dist != dist_two);
- BOOST_CHECK(!(dist == dist_two));
- BOOST_CHECK(dist_one != dist_two);
- BOOST_CHECK(!(dist_one == dist_two));
-}
+#define BOOST_RANDOM_DISTRIBUTION boost::random::weibull_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0.0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0.0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
-BOOST_AUTO_TEST_CASE(test_streaming) {
- boost::random::weibull_distribution<> dist(7.5, 0.25);
- std::stringstream stream;
- stream << dist;
- boost::random::weibull_distribution<> restored_dist;
- stream >> restored_dist;
- BOOST_CHECK_EQUAL(dist, restored_dist);
-}
+#define BOOST_RANDOM_TEST2_PARAMS (1.0, 1000000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
-BOOST_AUTO_TEST_CASE(test_generation) {
- boost::minstd_rand0 gen;
- boost::random::weibull_distribution<> dist;
- boost::random::weibull_distribution<> dist_two(1.0, 1000000.0);
- for(int i = 0; i < 10; ++i) {
- // This test is not guaranteed to work, since
- // a weibull distribution with a large scale parameter
- // can produce small values and a distribution with
- // a small scale can produce large values, but the
- // chances of failure are small.
- double value = dist(gen);
- BOOST_CHECK_GE(value, 0.0);
- BOOST_CHECK_LE(value, 100.0);
- double value_two = dist_two(gen);
- BOOST_CHECK_GE(value_two, 100.0);
- double value_param = dist_two(gen, dist.param());
- BOOST_CHECK_GE(value_param, 0);
- BOOST_CHECK_LE(value_param, 100.0);
- double value_two_param = dist(gen, dist_two.param());
- BOOST_CHECK_GE(value_two_param, 100.0);
- }
-}
+#include "test_distribution.ipp"
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk