diff --git a/test/cmake_jamfile b/test/cmake_jamfile index b9cd7c524..19f7e9978 100644 --- a/test/cmake_jamfile +++ b/test/cmake_jamfile @@ -16,4 +16,5 @@ run test_autodiff_1.cpp ; run test_polynomial.cpp ; # Distributions +run test_arcsine.cpp ; run test_binomial.cpp ; diff --git a/test/test_arcsine.cpp b/test/test_arcsine.cpp index 0c2d847a9..3b579e42d 100644 --- a/test/test_arcsine.cpp +++ b/test/test_arcsine.cpp @@ -10,7 +10,7 @@ // Tests for the arcsine Distribution. -#include // Must be 1st include, and include_directory /libs/math/src/tr1/ is needed. +// #include // Must be 1st include, and include_directory /libs/math/src/tr1/ is needed. #ifdef _MSC_VER # pragma warning(disable: 4127) // Conditional expression is constant. @@ -20,7 +20,6 @@ #include // for real_concept. using ::boost::math::concepts::real_concept; -#include // for real_concept. #include // for arcsine_distribution. using boost::math::arcsine_distribution; @@ -272,7 +271,7 @@ void test_spots(RealType) BOOST_CHECK_EQUAL(kurtosis_excess(arcsine_01), -1.5); // 3/2 BOOST_CHECK_EQUAL(support(arcsine_01).first, 0); // BOOST_CHECK_EQUAL(range(arcsine_01).first, 0); // - BOOST_MATH_CHECK_THROW(mode(arcsine_01), std::domain_error); // Two modes at x_min and x_max, so throw instead. + BOOST_CHECK_THROW(mode(arcsine_01), std::domain_error); // Two modes at x_min and x_max, so throw instead. // PDF // pdf of x = 1/4 is same as reflected value at x = 3/4. @@ -439,56 +438,56 @@ void test_spots(RealType) BOOST_CHECK_CLOSE_FRACTION(quantile(complement(as_m2m1, static_cast(0.85643370687129372924905811522494428117838480010259L))), -static_cast(1.95L), 4 * tolerance); // Tests that should throw: - BOOST_MATH_CHECK_THROW(mode(arcsine_distribution(static_cast(0), static_cast(1))), std::domain_error); + BOOST_CHECK_THROW(mode(arcsine_distribution(static_cast(0), static_cast(1))), std::domain_error); // mode is undefined, and must throw domain_error! - BOOST_MATH_CHECK_THROW( // For various bad arguments. + BOOST_CHECK_THROW( // For various bad arguments. pdf( arcsine_distribution(static_cast(+1), static_cast(-1)), // min_x > max_x static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( pdf( arcsine_distribution(static_cast(1), static_cast(0)), // bad constructor parameters. static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( pdf( arcsine_distribution(static_cast(1), static_cast(-1)), // bad constructor parameters. static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( pdf( arcsine_distribution(static_cast(1), static_cast(1)), // equal constructor parameters. static_cast(-1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( pdf( arcsine_distribution(static_cast(0), static_cast(1)), // bad x > 1. static_cast(999)), std::domain_error); - BOOST_MATH_CHECK_THROW( // For various bad arguments. + BOOST_CHECK_THROW( // For various bad arguments. logpdf( arcsine_distribution(static_cast(+1), static_cast(-1)), // min_x > max_x static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( logpdf( arcsine_distribution(static_cast(1), static_cast(0)), // bad constructor parameters. static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( logpdf( arcsine_distribution(static_cast(1), static_cast(-1)), // bad constructor parameters. static_cast(1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( logpdf( arcsine_distribution(static_cast(1), static_cast(1)), // equal constructor parameters. static_cast(-1)), std::domain_error); - BOOST_MATH_CHECK_THROW( + BOOST_CHECK_THROW( logpdf( arcsine_distribution(static_cast(0), static_cast(1)), // bad x > 1. static_cast(999)), std::domain_error); @@ -496,26 +495,26 @@ void test_spots(RealType) // Checks on things that are errors. // Construction with 'bad' parameters. - BOOST_MATH_CHECK_THROW(arcsine_distribution(+1, -1), std::domain_error); // max < min. - BOOST_MATH_CHECK_THROW(arcsine_distribution(+1, 0), std::domain_error); // max < min. + BOOST_CHECK_THROW(arcsine_distribution(+1, -1), std::domain_error); // max < min. + BOOST_CHECK_THROW(arcsine_distribution(+1, 0), std::domain_error); // max < min. arcsine_distribution<> dist; - BOOST_MATH_CHECK_THROW(pdf(dist, -1), std::domain_error); - BOOST_MATH_CHECK_THROW(logpdf(dist, -1), std::domain_error); - BOOST_MATH_CHECK_THROW(cdf(dist, -1), std::domain_error); - BOOST_MATH_CHECK_THROW(cdf(complement(dist, -1)), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(dist, -1), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(complement(dist, -1)), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(dist, -1), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(complement(dist, -1)), std::domain_error); + BOOST_CHECK_THROW(pdf(dist, -1), std::domain_error); + BOOST_CHECK_THROW(logpdf(dist, -1), std::domain_error); + BOOST_CHECK_THROW(cdf(dist, -1), std::domain_error); + BOOST_CHECK_THROW(cdf(complement(dist, -1)), std::domain_error); + BOOST_CHECK_THROW(quantile(dist, -1), std::domain_error); + BOOST_CHECK_THROW(quantile(complement(dist, -1)), std::domain_error); + BOOST_CHECK_THROW(quantile(dist, -1), std::domain_error); + BOOST_CHECK_THROW(quantile(complement(dist, -1)), std::domain_error); // Various combinations of bad constructor and member function parameters. - BOOST_MATH_CHECK_THROW(pdf(boost::math::arcsine_distribution(0, 1), -1), std::domain_error); - BOOST_MATH_CHECK_THROW(pdf(boost::math::arcsine_distribution(-1, 1), +2), std::domain_error); - BOOST_MATH_CHECK_THROW(logpdf(boost::math::arcsine_distribution(0, 1), -1), std::domain_error); - BOOST_MATH_CHECK_THROW(logpdf(boost::math::arcsine_distribution(-1, 1), +2), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(boost::math::arcsine_distribution(1, 1), -1), std::domain_error); - BOOST_MATH_CHECK_THROW(quantile(boost::math::arcsine_distribution(1, 1), 2), std::domain_error); + BOOST_CHECK_THROW(pdf(boost::math::arcsine_distribution(0, 1), -1), std::domain_error); + BOOST_CHECK_THROW(pdf(boost::math::arcsine_distribution(-1, 1), +2), std::domain_error); + BOOST_CHECK_THROW(logpdf(boost::math::arcsine_distribution(0, 1), -1), std::domain_error); + BOOST_CHECK_THROW(logpdf(boost::math::arcsine_distribution(-1, 1), +2), std::domain_error); + BOOST_CHECK_THROW(quantile(boost::math::arcsine_distribution(1, 1), -1), std::domain_error); + BOOST_CHECK_THROW(quantile(boost::math::arcsine_distribution(1, 1), 2), std::domain_error); // No longer allow any parameter to be NaN or inf, so all these tests should throw. if (std::numeric_limits::has_quiet_NaN) @@ -523,23 +522,23 @@ void test_spots(RealType) // Attempt to construct from non-finite parameters should throw. RealType nan = std::numeric_limits::quiet_NaN(); #ifndef BOOST_NO_EXCEPTIONS - BOOST_MATH_CHECK_THROW(arcsine_distribution w(nan), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution w(1, nan), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution w(nan, 1), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(nan), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(1, nan), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(nan, 1), std::domain_error); #else - BOOST_MATH_CHECK_THROW(arcsine_distribution(nan), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution(1, nan), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution(nan, 1), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(nan), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(1, nan), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(nan, 1), std::domain_error); #endif arcsine_distribution w(RealType(-1), RealType(+1)); // NaN parameters to member functions should throw. - BOOST_MATH_CHECK_THROW(pdf(w, +nan), std::domain_error); // x = NaN - BOOST_MATH_CHECK_THROW(logpdf(w, +nan), std::domain_error); // x = NaN - BOOST_MATH_CHECK_THROW(cdf(w, +nan), std::domain_error); // x = NaN - BOOST_MATH_CHECK_THROW(cdf(complement(w, +nan)), std::domain_error); // x = + nan - BOOST_MATH_CHECK_THROW(quantile(w, +nan), std::domain_error); // p = + nan - BOOST_MATH_CHECK_THROW(quantile(complement(w, +nan)), std::domain_error); // p = + nan + BOOST_CHECK_THROW(pdf(w, +nan), std::domain_error); // x = NaN + BOOST_CHECK_THROW(logpdf(w, +nan), std::domain_error); // x = NaN + BOOST_CHECK_THROW(cdf(w, +nan), std::domain_error); // x = NaN + BOOST_CHECK_THROW(cdf(complement(w, +nan)), std::domain_error); // x = + nan + BOOST_CHECK_THROW(quantile(w, +nan), std::domain_error); // p = + nan + BOOST_CHECK_THROW(quantile(complement(w, +nan)), std::domain_error); // p = + nan } // has_quiet_NaN if (std::numeric_limits::has_infinity) @@ -547,27 +546,27 @@ void test_spots(RealType) // Attempt to construct from non-finite should throw. RealType inf = std::numeric_limits::infinity(); #ifndef BOOST_NO_EXCEPTIONS - BOOST_MATH_CHECK_THROW(arcsine_distribution w(inf), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution w(1, inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(1, inf), std::domain_error); #else - BOOST_MATH_CHECK_THROW(arcsine_distribution(inf), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution(1, inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(1, inf), std::domain_error); #endif // Infinite parameters to member functions should throw. arcsine_distribution w(RealType(0), RealType(1)); #ifndef BOOST_NO_EXCEPTIONS - BOOST_MATH_CHECK_THROW(arcsine_distribution w(inf), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution w(1, inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution w(1, inf), std::domain_error); #else - BOOST_MATH_CHECK_THROW(arcsine_distribution(inf), std::domain_error); - BOOST_MATH_CHECK_THROW(arcsine_distribution(1, inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(inf), std::domain_error); + BOOST_CHECK_THROW(arcsine_distribution(1, inf), std::domain_error); #endif - BOOST_MATH_CHECK_THROW(pdf(w, +inf), std::domain_error); // x = inf - BOOST_MATH_CHECK_THROW(logpdf(w, +inf), std::domain_error); // x = inf - BOOST_MATH_CHECK_THROW(cdf(w, +inf), std::domain_error); // x = inf - BOOST_MATH_CHECK_THROW(cdf(complement(w, +inf)), std::domain_error); // x = + inf - BOOST_MATH_CHECK_THROW(quantile(w, +inf), std::domain_error); // p = + inf - BOOST_MATH_CHECK_THROW(quantile(complement(w, +inf)), std::domain_error); // p = + inf + BOOST_CHECK_THROW(pdf(w, +inf), std::domain_error); // x = inf + BOOST_CHECK_THROW(logpdf(w, +inf), std::domain_error); // x = inf + BOOST_CHECK_THROW(cdf(w, +inf), std::domain_error); // x = inf + BOOST_CHECK_THROW(cdf(complement(w, +inf)), std::domain_error); // x = + inf + BOOST_CHECK_THROW(quantile(w, +inf), std::domain_error); // p = + inf + BOOST_CHECK_THROW(quantile(complement(w, +inf)), std::domain_error); // p = + inf } // has_infinity // Error handling checks: @@ -601,7 +600,7 @@ void test_spots(RealType) BOOST_CHECK_EQUAL(kurtosis_excess(as), -1.5); // 3/2 BOOST_CHECK_EQUAL(support(as).first, 0); // BOOST_CHECK_EQUAL(range(as).first, 0); // - BOOST_MATH_CHECK_THROW(mode(as), std::domain_error); // Two modes at x_min and x_max, so throw instead. + BOOST_CHECK_THROW(mode(as), std::domain_error); // Two modes at x_min and x_max, so throw instead. // (Parameter value, arbitrarily zero, only communicates the floating point type). test_spots(0.0F); // Test float.