]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // test file for special functions. |
2 | ||
3 | // (C) Copyright Hubert Holin 2003. | |
4 | // Distributed under the Boost Software License, Version 1.0. (See | |
5 | // accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | ||
9 | #include <iomanip> | |
10 | ||
11 | ||
12 | #include <boost/mpl/list.hpp> | |
13 | ||
14 | #include <boost/test/unit_test.hpp> | |
15 | #include <boost/test/unit_test_log.hpp> | |
16 | #include <boost/math/tools/config.hpp> | |
17 | #include <boost/math/tools/test.hpp> | |
18 | ||
19 | ||
20 | template<typename T> | |
21 | struct string_type_name; | |
22 | ||
23 | #define DEFINE_TYPE_NAME(Type) \ | |
24 | template<> struct string_type_name<Type> \ | |
25 | { \ | |
26 | static char const * _() \ | |
27 | { \ | |
28 | return #Type; \ | |
29 | } \ | |
30 | } | |
31 | ||
32 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
33 | DEFINE_TYPE_NAME(float); | |
34 | DEFINE_TYPE_NAME(double); | |
35 | DEFINE_TYPE_NAME(long double); | |
36 | ||
37 | typedef boost::mpl::list<float,double,long double> test_types; | |
38 | #else | |
39 | DEFINE_TYPE_NAME(float); | |
40 | DEFINE_TYPE_NAME(double); | |
41 | ||
42 | typedef boost::mpl::list<float,double> test_types; | |
43 | #endif | |
44 | ||
45 | // Apple GCC 4.0 uses the "double double" format for its long double, | |
46 | // which means that epsilon is VERY small but useless for | |
47 | // comparisons. So, don't do those comparisons. | |
48 | #if (defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ == 4) || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS) | |
49 | typedef boost::mpl::list<float,double> near_eps_test_types; | |
50 | #else | |
51 | typedef boost::mpl::list<float,double,long double> near_eps_test_types; | |
52 | #endif | |
53 | ||
54 | #include "sinc_test.hpp" | |
55 | #include "sinhc_test.hpp" | |
56 | #include "atanh_test.hpp" | |
57 | #include "asinh_test.hpp" | |
58 | #include "acosh_test.hpp" | |
59 | ||
60 | ||
61 | ||
62 | boost::unit_test::test_suite * init_unit_test_suite(int, char *[]) | |
63 | { | |
64 | ::boost::unit_test::unit_test_log. | |
65 | set_threshold_level(::boost::unit_test::log_messages); | |
66 | ||
67 | boost::unit_test::test_suite * test = | |
68 | BOOST_TEST_SUITE("special_functions_test"); | |
69 | ||
70 | BOOST_TEST_MESSAGE("Results of special functions test."); | |
71 | BOOST_TEST_MESSAGE(" "); | |
72 | BOOST_TEST_MESSAGE("(C) Copyright Hubert Holin 2003-2005."); | |
73 | BOOST_TEST_MESSAGE("Distributed under the Boost Software License, Version 1.0."); | |
74 | BOOST_TEST_MESSAGE("(See accompanying file LICENSE_1_0.txt or copy at"); | |
75 | BOOST_TEST_MESSAGE("http://www.boost.org/LICENSE_1_0.txt)"); | |
76 | BOOST_TEST_MESSAGE(" "); | |
77 | ||
78 | #define BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(fct) \ | |
79 | test->add(BOOST_TEST_CASE_TEMPLATE(fct##_test, test_types)); | |
80 | ||
81 | #define BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR_NEAR_EPS(fct) \ | |
82 | test->add(BOOST_TEST_CASE_TEMPLATE(fct##_test, near_eps_test_types)); | |
83 | ||
84 | ||
85 | #define BOOST_SPECIAL_FUNCTIONS_COMMON_TEST \ | |
86 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(atanh) \ | |
87 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(asinh) \ | |
88 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(acosh) \ | |
89 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(sinc_pi) \ | |
90 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR(sinhc_pi) | |
91 | ||
92 | #define BOOST_SPECIAL_FUNCTIONS_TEMPLATE_TEMPLATE_TEST \ | |
93 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR_NEAR_EPS(sinc_pi_complex) \ | |
94 | BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR_NEAR_EPS(sinhc_pi_complex) | |
95 | ||
96 | ||
97 | #ifdef BOOST_NO_TEMPLATE_TEMPLATES | |
98 | ||
99 | #define BOOST_SPECIAL_FUNCTIONS_TEST \ | |
100 | BOOST_SPECIAL_FUNCTIONS_COMMON_TEST \ | |
101 | BOOST_TEST_MESSAGE("Warning: no template templates; curtailed functionality."); | |
102 | ||
103 | #else /* BOOST_NO_TEMPLATE_TEMPLATES */ | |
104 | ||
105 | #define BOOST_SPECIAL_FUNCTIONS_TEST \ | |
106 | BOOST_SPECIAL_FUNCTIONS_COMMON_TEST \ | |
107 | BOOST_SPECIAL_FUNCTIONS_TEMPLATE_TEMPLATE_TEST | |
108 | ||
109 | #endif /* BOOST_NO_TEMPLATE_TEMPLATES */ | |
110 | ||
111 | ||
112 | BOOST_SPECIAL_FUNCTIONS_TEST | |
113 | ||
114 | ||
115 | #undef BOOST_SPECIAL_FUNCTIONS_TEST | |
116 | ||
117 | #undef BOOST_SPECIAL_FUNCTIONS_TEMPLATE_TEMPLATE_TEST | |
118 | ||
119 | #undef BOOST_SPECIAL_FUNCTIONS_COMMON_TEST | |
120 | ||
121 | #undef BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR | |
122 | ||
123 | #undef BOOST_SPECIAL_FUNCTIONS_COMMON_GENERATOR_NEAR_EPS | |
124 | ||
125 | #ifdef BOOST_SPECIAL_FUNCTIONS_TEST_VERBOSE | |
126 | ||
127 | using ::std::numeric_limits; | |
128 | ||
129 | BOOST_TEST_MESSAGE("epsilon"); | |
130 | ||
131 | BOOST_TEST_MESSAGE( ::std::setw(15) << numeric_limits<float>::epsilon() | |
132 | << ::std::setw(15) << numeric_limits<double>::epsilon() | |
133 | << ::std::setw(15) << numeric_limits<long double>::epsilon()); | |
134 | ||
135 | BOOST_TEST_MESSAGE(" "); | |
136 | ||
137 | test->add(BOOST_TEST_CASE(atanh_manual_check)); | |
138 | test->add(BOOST_TEST_CASE(asinh_manual_check)); | |
139 | test->add(BOOST_TEST_CASE(acosh_manual_check)); | |
140 | test->add(BOOST_TEST_CASE(sinc_pi_manual_check)); | |
141 | test->add(BOOST_TEST_CASE(sinhc_pi_manual_check)); | |
142 | ||
143 | #endif /* BOOST_SPECIAL_FUNCTIONS_TEST_VERBOSE */ | |
144 | ||
145 | return test; | |
146 | } | |
147 | ||
148 | #undef DEFINE_TYPE_NAME |