• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright 2013 John Maddock. Distributed under the Boost
2 //  Software License, Version 1.0. (See accompanying file
3 //  LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef BOOST_MP_MATH_SETUP_HPP
6 #define BOOST_MP_MATH_SETUP_HPP
7 
8 #ifdef _MSC_VER
9 #define _SCL_SECURE_NO_WARNINGS
10 #endif
11 
12 #define BOOST_MATH_OVERFLOW_ERROR_POLICY ignore_error
13 #undef BOOST_MATH_SMALL_CONSTANT
14 #define BOOST_MATH_SMALL_CONSTANT(x) x
15 
16 #if !defined(TEST_MPF_50) && !defined(TEST_BACKEND) && !defined(TEST_CPP_DEC_FLOAT) && !defined(TEST_MPFR_50) && !defined(TEST_FLOAT128) && !defined(TEST_CPP_BIN_FLOAT)
17 #define TEST_MPF_50
18 #define TEST_MPFR_50
19 #define TEST_CPP_DEC_FLOAT
20 #define TEST_FLOAT128
21 #define TEST_CPP_BIN_FLOAT
22 
23 #ifdef _MSC_VER
24 #pragma message("CAUTION!!: No backend type specified so testing everything.... this will take some time!!")
25 #endif
26 #ifdef __GNUC__
27 #pragma warning "CAUTION!!: No backend type specified so testing everything.... this will take some time!!"
28 #endif
29 
30 #endif
31 
32 #if defined(TEST_MPF_50)
33 #include <boost/multiprecision/gmp.hpp>
34 #include <boost/multiprecision/debug_adaptor.hpp>
35 
36 #define MPF_TESTS /*test(number<gmp_float<18> >(), "number<gmp_float<18> >");*/ \
37    mpf_float::default_precision(20);                                            \
38    test(mpf_float(), "number<gmp_float<0> > (20 digit precision)");             \
39    mpf_float::default_precision(35);                                            \
40    test(mpf_float(), "number<gmp_float<0> > (35 digit precision)");             \
41    test(number<gmp_float<30> >(), "number<gmp_float<30> >");                    \
42    test(number<gmp_float<35> >(), "number<gmp_float<35> >");                    \
43    /* there should be at least one test with expression templates off: */       \
44    test(number<gmp_float<35>, et_off>(), "number<gmp_float<35>, et_off>");
45 #define MPF_SMALL_TESTS /*test(number<gmp_float<18> >(), "number<gmp_float<18> >");*/ \
46    test(number<gmp_float<30> >(), "number<gmp_float<30> >");                          \
47    test(number<gmp_float<35> >(), "number<gmp_float<35> >");                          \
48    /* there should be at least one test with expression templates off: */             \
49    test(number<gmp_float<35>, et_off>(), "number<gmp_float<35>, et_off>");            \
50    mpf_float::default_precision(20);                                                  \
51    test(mpf_float(), "number<gmp_float<0> > (20 digit precision)");                   \
52    mpf_float::default_precision(35);                                                  \
53    test(mpf_float(), "number<gmp_float<0> > (35 digit precision)");
54 
55 typedef boost::multiprecision::number<boost::multiprecision::gmp_float<18> >                               test_type_1;
56 typedef boost::multiprecision::number<boost::multiprecision::gmp_float<30> >                               test_type_2;
57 typedef boost::multiprecision::number<boost::multiprecision::gmp_float<35> >                               test_type_3;
58 typedef boost::multiprecision::number<boost::multiprecision::gmp_float<35>, boost::multiprecision::et_off> test_type_4;
59 typedef boost::multiprecision::mpf_float                                                                   test_type_5;
60 
61 #else
62 
63 #define MPF_TESTS
64 #define MPF_SMALL_TESTS
65 
66 #endif
67 
68 #if defined(TEST_MPFR_50)
69 #include <boost/multiprecision/mpfr.hpp>
70 
71 #define MPFR_TESTS                                                                                                     \
72    test(number<mpfr_float_backend<18> >(), "number<mpfr_float_backend<18> >");                                         \
73    test(number<mpfr_float_backend<30> >(), "number<mpfr_float_backend<30> >");                                         \
74    test(number<mpfr_float_backend<35> >(), "number<mpfr_float_backend<35> >");                                         \
75    /* Test variable precision at 2 different precisions - checks our ability to handle dynamic changes in precision */ \
76    mpfr_float::default_precision(20);                                                                                  \
77    test(mpfr_float(), "number<mpfr_float_backend<0> > (20-digit precision)");                                          \
78    mpfr_float::default_precision(35);                                                                                  \
79    test(mpfr_float(), "number<mpfr_float_backend<0> > (35-digit precision)");
80 
81 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<18> > test_type_1;
82 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<30> > test_type_2;
83 typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<35> > test_type_3;
84 typedef boost::multiprecision::mpfr_float                                             test_type_4;
85 
86 #else
87 
88 #define MPFR_TESTS
89 
90 #endif
91 
92 #ifdef TEST_BACKEND
93 #include <boost/multiprecision/concepts/mp_number_archetypes.hpp>
94 #endif
95 #ifdef TEST_CPP_DEC_FLOAT
96 #include <boost/multiprecision/cpp_dec_float.hpp>
97 
98 #define CPP_DEC_FLOAT_TESTS                                          \
99    test(number<cpp_dec_float<18> >(), "number<cpp_dec_float<18> >"); \
100    test(number<cpp_dec_float<30> >(), "number<cpp_dec_float<30> >"); \
101    test(number<cpp_dec_float<35, long long, std::allocator<char> > >(), "number<cpp_dec_float<35, long long, std::allocator<char> > >");
102 
103 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<18> >                                   test_type_1;
104 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<30> >                                   test_type_2;
105 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<35, long long, std::allocator<char> > > test_type_3;
106 
107 #else
108 
109 #define CPP_DEC_FLOAT_TESTS
110 
111 #endif
112 
113 #ifdef TEST_CPP_BIN_FLOAT
114 #include <boost/multiprecision/cpp_bin_float.hpp>
115 #include <boost/multiprecision/debug_adaptor.hpp>
116 
117 //#define CPP_BIN_FLOAT_TESTS test(number<debug_adaptor<cpp_bin_float_quad::backend_type>, et_off>(), "cpp_bin_float_quad");
118 #define CPP_BIN_FLOAT_TESTS test(cpp_bin_float_quad(), "cpp_bin_float_quad");
119 
120 //typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::cpp_bin_float_quad::backend_type>, boost::multiprecision::et_off> test_type_1;
121 typedef boost::multiprecision::cpp_bin_float_quad test_type_1;
122 
123 #else
124 
125 #define CPP_BIN_FLOAT_TESTS
126 
127 #endif
128 
129 #ifdef TEST_FLOAT128
130 #include <boost/multiprecision/float128.hpp>
131 
132 #define FLOAT128_TESTS test(float128(), "float128");
133 
134 typedef boost::multiprecision::float128 test_type_1;
135 
136 #else
137 
138 #define FLOAT128_TESTS
139 
140 #endif
141 
142 #ifndef BOOST_MATH_TEST_TYPE
143 #define BOOST_TEST_MAIN
144 #include <boost/test/unit_test.hpp>
145 #include <boost/test/floating_point_comparison.hpp>
146 #endif
147 
148 #define ALL_TESTS      \
149    MPF_TESTS           \
150    MPFR_TESTS          \
151    CPP_DEC_FLOAT_TESTS \
152    FLOAT128_TESTS      \
153    CPP_BIN_FLOAT_TESTS
154 
155 #define ALL_SMALL_TESTS \
156    MPF_SMALL_TESTS      \
157    MPFR_TESTS           \
158    CPP_DEC_FLOAT_TESTS  \
159    FLOAT128_TESTS       \
160    CPP_BIN_FLOAT_TESTS
161 
162 #endif
163