Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78726 - in trunk: boost/math/distributions libs/math/test
From: john_at_[hidden]
Date: 2012-05-28 13:42:51


Author: johnmaddock
Date: 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
New Revision: 78726
URL: http://svn.boost.org/trac/boost/changeset/78726

Log:
Improve testing of error conditions and fix any errors detected.
Takes care of distributions normal-weibull.
Refs #6937.
Text files modified:
   trunk/boost/math/distributions/students_t.hpp | 4 ++--
   trunk/libs/math/test/test_normal.cpp | 6 +++++-
   trunk/libs/math/test/test_pareto.cpp | 11 +++++++++++
   trunk/libs/math/test/test_skew_normal.cpp | 5 ++++-
   trunk/libs/math/test/test_students_t.cpp | 4 ++++
   5 files changed, 26 insertions(+), 4 deletions(-)

Modified: trunk/boost/math/distributions/students_t.hpp
==============================================================================
--- trunk/boost/math/distributions/students_t.hpp (original)
+++ trunk/boost/math/distributions/students_t.hpp 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
@@ -163,9 +163,9 @@
    //
    static const char* function = "boost::math::quantile(const students_t_distribution<%1%>&, %1%)";
    RealType error_result;
- if(false == detail::check_df(
+ if(false == (detail::check_df(
       function, degrees_of_freedom, &error_result, Policy())
- && detail::check_probability(function, probability, &error_result, Policy()))
+ && detail::check_probability(function, probability, &error_result, Policy())))
       return error_result;
 
    // Special cases, regardless of degrees_of_freedom.

Modified: trunk/libs/math/test/test_normal.cpp
==============================================================================
--- trunk/libs/math/test/test_normal.cpp (original)
+++ trunk/libs/math/test/test_normal.cpp 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
@@ -282,7 +282,11 @@
        standard_deviation(def_norm01),
        static_cast<RealType>(1), 0); // Mean == zero
 
-
+ // Error tests:
+ BOOST_CHECK_THROW(pdf(normal_distribution<RealType>(0, 0), 0), std::domain_error);
+ BOOST_CHECK_THROW(pdf(normal_distribution<RealType>(0, -1), 0), std::domain_error);
+ BOOST_CHECK_THROW(quantile(normal_distribution<RealType>(0, 1), -1), std::domain_error);
+ BOOST_CHECK_THROW(quantile(normal_distribution<RealType>(0, 1), 2), std::domain_error);
 } // template <class RealType>void test_spots(RealType)
 
 int test_main(int, char* [])

Modified: trunk/libs/math/test/test_pareto.cpp
==============================================================================
--- trunk/libs/math/test/test_pareto.cpp (original)
+++ trunk/libs/math/test/test_pareto.cpp 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
@@ -232,6 +232,17 @@
       kurtosis_excess(pareto15), kurtosis(pareto15) - static_cast<RealType>(3L), tol5eps);
     // Check kurtosis excess = kurtosis - 3;
 
+ // Error condition checks:
+ BOOST_CHECK_THROW(pdf(pareto_distribution<RealType>(0, 1), 0), std::domain_error);
+ BOOST_CHECK_THROW(pdf(pareto_distribution<RealType>(1, 0), 0), std::domain_error);
+ BOOST_CHECK_THROW(pdf(pareto_distribution<RealType>(-1, 1), 0), std::domain_error);
+ BOOST_CHECK_THROW(pdf(pareto_distribution<RealType>(1, -1), 0), std::domain_error);
+
+ BOOST_CHECK_THROW(pdf(pareto_distribution<RealType>(1, 1), 0), std::domain_error);
+ BOOST_CHECK_THROW(cdf(pareto_distribution<RealType>(1, 1), 0), std::domain_error);
+
+ BOOST_CHECK_THROW(quantile(pareto_distribution<RealType>(1, 1), -1), std::domain_error);
+ BOOST_CHECK_THROW(quantile(pareto_distribution<RealType>(1, 1), 2), std::domain_error);
 } // template <class RealType>void test_spots(RealType)
 
 int test_main(int, char* [])

Modified: trunk/libs/math/test/test_skew_normal.cpp
==============================================================================
--- trunk/libs/math/test/test_skew_normal.cpp (original)
+++ trunk/libs/math/test/test_skew_normal.cpp 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
@@ -436,7 +436,10 @@
            , static_cast<RealType>(0.8638862008406084244563L), tol1000);
       }
 
-
+ BOOST_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, 0, 0), 0), std::domain_error);
+ BOOST_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, -1, 0), 0), std::domain_error);
+ BOOST_CHECK_THROW(quantile(skew_normal_distribution<RealType>(0, 1, 0), -1), std::domain_error);
+ BOOST_CHECK_THROW(quantile(skew_normal_distribution<RealType>(0, 1, 0), 2), std::domain_error);
     }
 
 

Modified: trunk/libs/math/test/test_students_t.cpp
==============================================================================
--- trunk/libs/math/test/test_students_t.cpp (original)
+++ trunk/libs/math/test/test_students_t.cpp 2012-05-28 13:42:50 EDT (Mon, 28 May 2012)
@@ -465,6 +465,10 @@
          static_cast<RealType>(1.0))),
          9);
 
+ BOOST_CHECK_THROW(quantile(dist, -1), std::domain_error);
+ BOOST_CHECK_THROW(quantile(dist, 2), std::domain_error);
+ BOOST_CHECK_THROW(pdf(students_t_distribution<RealType>(0), 0), std::domain_error);
+ BOOST_CHECK_THROW(pdf(students_t_distribution<RealType>(-1), 0), std::domain_error);
 } // template <class RealType>void test_spots(RealType)
 
 int test_main(int, char* [])


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