Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / math / test / test_normal.cpp
index 3dfb943..9b85b3f 100644 (file)
 #include <pch.hpp> // include directory /libs/math/src/tr1/ is needed.
 
 #ifdef _MSC_VER
-#pragma warning (disable: 4127) // conditional expression is constant
+#  pragma warning (disable: 4127) // conditional expression is constant
 // caused by using   if(std::numeric_limits<RealType>::has_infinity)
 // and   if (std::numeric_limits<RealType>::has_quiet_NaN)
 #endif
 
 #include <boost/math/concepts/real_concept.hpp> // for real_concept
-#include <boost/test/test_exec_monitor.hpp> // Boost.Test
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp> // Boost.Test
 #include <boost/test/floating_point_comparison.hpp>
 
 #include <boost/math/distributions/normal.hpp>
     using boost::math::normal_distribution;
 #include <boost/math/tools/test.hpp>
+#include "test_out_of_range.hpp"
 
 #include <iostream>
+#include <iomanip>
    using std::cout;
    using std::endl;
    using std::setprecision;
@@ -92,7 +95,7 @@ void test_spots(RealType)
    BOOST_CHECK_THROW(boost::math::normal_distribution<RealType> nbad1(0, 0), std::domain_error); // zero sd
    BOOST_CHECK_THROW(boost::math::normal_distribution<RealType> nbad1(0, -1), std::domain_error); // negative sd
 
-  // Tests on extreme values of random variate x, if has numeric_limit infinity etc.
+  // Tests on extreme values of random variate x, if has std::numeric_limits infinity etc.
     normal_distribution<RealType> N01;
   if(std::numeric_limits<RealType>::has_infinity)
   {
@@ -282,10 +285,16 @@ void test_spots(RealType)
        standard_deviation(def_norm01),
        static_cast<RealType>(1), 0); // Mean == zero
 
-
+    // Error tests:
+    check_out_of_range<boost::math::normal_distribution<RealType> >(0, 1); // (All) valid constructor parameter values.
+    
+    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* [])
+BOOST_AUTO_TEST_CASE( test_main )
 {
     // Check that can generate normal distribution using the two convenience methods:
    boost::math::normal myf1(1., 2); // Using typedef
@@ -313,8 +322,8 @@ int test_main(int, char* [])
       "to pass.</note>" << std::cout;
 #endif
 
-   return 0;
-} // int test_main(int, char* [])
+   
+} // BOOST_AUTO_TEST_CASE( test_main )
 
 /*