]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/interval/test/overflow.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / numeric / interval / test / overflow.cpp
1 /* Boost test/overflow.cpp
2 * test if extended precision exponent does not disturb interval computation
3 *
4 * Copyright 2002-2003 Guillaume Melquiond
5 *
6 * Distributed under the Boost Software License, Version 1.0.
7 * (See accompanying file LICENSE_1_0.txt or
8 * copy at http://www.boost.org/LICENSE_1_0.txt)
9 */
10
11 #include <boost/numeric/interval.hpp>
12 #include <boost/test/minimal.hpp>
13 #include "bugs.hpp"
14
15 template<class I>
16 void test_one(typename I::base_type x, typename I::base_type f) {
17 I y = x;
18 typename I::base_type g = 1 / f;
19 const int nb = 10000;
20 for(int i = 0; i < nb; i++) y *= f;
21 for(int i = 0; i < nb; i++) y *= g;
22 BOOST_CHECK(in(x, y));
23 # ifdef BOOST_BORLANDC
24 ::detail::ignore_unused_variable_warning(nb);
25 # endif
26 }
27
28 template<class I>
29 void test() {
30 test_one<I>(1., 25.);
31 test_one<I>(1., 0.04);
32 test_one<I>(-1., 25.);
33 test_one<I>(-1., 0.04);
34 }
35
36 int test_main(int, char *[]) {
37 test<boost::numeric::interval<float> >();
38 test<boost::numeric::interval<double> >();
39 //test<boost::numeric::interval<long double> >();
40 # ifdef BOOST_BORLANDC
41 ::detail::ignore_warnings();
42 # endif
43 return 0;
44 }