1 // (C) Copyright John Maddock 2006.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #include "test_2F0.hpp"
7
8 #include <boost/multiprecision/cpp_bin_float.hpp>
9 #include <boost/multiprecision/cpp_dec_float.hpp>
10
expected_results()11 void expected_results()
12 {
13 //
14 // Define the max and mean errors expected for
15 // various compilers and platforms.
16 //
17 const char* largest_type;
18 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
19 if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
20 {
21 largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40";
22 }
23 else
24 {
25 largest_type = "long double|real_concept|cpp_bin_float_quad|dec_40";
26 }
27 #else
28 largest_type = "(long\\s+)?double|cpp_bin_float_quad|dec_40";
29 #endif
30
31 if (boost::math::policies::digits<double, boost::math::policies::policy<> >() != boost::math::policies::digits<long double, boost::math::policies::policy<> >())
32 {
33 add_expected_result(
34 ".*", // compiler
35 ".*", // stdlib
36 ".*", // platform
37 "double", // test type(s)
38 "Random non-integer a2.*", // test data group
39 ".*", 10, 5); // test function
40 add_expected_result(
41 ".*", // compiler
42 ".*", // stdlib
43 ".*", // platform
44 "double", // test type(s)
45 "a1 = a2 \\+ 0\\.5", // test data group
46 ".*", 10, 5); // test function
47 }
48
49 add_expected_result(
50 ".*", // compiler
51 ".*", // stdlib
52 ".*", // platform
53 largest_type, // test type(s)
54 "Random non-integer a2.*", // test data group
55 ".*", 9000, 3000); // test function
56 add_expected_result(
57 ".*", // compiler
58 ".*", // stdlib
59 ".*", // platform
60 largest_type, // test type(s)
61 "Integer.*", // test data group
62 ".*", 300, 100); // test function
63 add_expected_result(
64 ".*", // compiler
65 ".*", // stdlib
66 ".*", // platform
67 largest_type, // test type(s)
68 "a1 = a2 \\+ 0\\.5", // test data group
69 ".*", 2000, 200); // test function
70
71 //
72 // Finish off by printing out the compiler/stdlib/platform names,
73 // we do this to make it easier to mark up expected error rates.
74 //
75 std::cout << "Tests run with " << BOOST_COMPILER << ", "
76 << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
77 }
78
BOOST_AUTO_TEST_CASE(test_main)79 BOOST_AUTO_TEST_CASE( test_main )
80 {
81 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<40> > dec_40;
82 expected_results();
83 BOOST_MATH_CONTROL_FP;
84
85 #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
86 test_spots(0.0F, "float");
87 #endif
88 test_spots(0.0, "double");
89 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
90 test_spots(0.0L, "long double");
91 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
92 test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
93 #endif
94 #endif
95 test_spots(boost::multiprecision::cpp_bin_float_quad(), "cpp_bin_float_quad");
96 test_spots(dec_40(), "dec_40");
97 }
98