]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* Boost test/pow.cpp |
2 | * test the pow function | |
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> | |
1e59de90 | 12 | #include <boost/core/lightweight_test.hpp> |
7c673cae FG |
13 | #include "bugs.hpp" |
14 | ||
15 | bool test_pow(double al, double au, double bl, double bu, int p) { | |
16 | typedef boost::numeric::interval<double> I; | |
17 | I b = pow(I(al, au), p); | |
18 | return b.lower() == bl && b.upper() == bu; | |
19 | } | |
20 | ||
1e59de90 TL |
21 | int main() { |
22 | BOOST_TEST(test_pow(2, 3, 8, 27, 3)); | |
23 | BOOST_TEST(test_pow(2, 3, 16, 81, 4)); | |
24 | BOOST_TEST(test_pow(-3, 2, -27, 8, 3)); | |
25 | BOOST_TEST(test_pow(-3, 2, 0, 81, 4)); | |
26 | BOOST_TEST(test_pow(-3, -2, -27, -8, 3)); | |
27 | BOOST_TEST(test_pow(-3, -2, 16, 81, 4)); | |
7c673cae | 28 | |
1e59de90 TL |
29 | BOOST_TEST(test_pow(2, 4, 1./64, 1./8, -3)); |
30 | BOOST_TEST(test_pow(2, 4, 1./256, 1./16, -4)); | |
31 | BOOST_TEST(test_pow(-4, -2, -1./8, -1./64, -3)); | |
32 | BOOST_TEST(test_pow(-4, -2, 1./256, 1./16, -4)); | |
7c673cae | 33 | |
1e59de90 TL |
34 | BOOST_TEST(test_pow(2, 3, 1, 1, 0)); |
35 | BOOST_TEST(test_pow(-3, 2, 1, 1, 0)); | |
36 | BOOST_TEST(test_pow(-3, -2, 1, 1, 0)); | |
7c673cae | 37 | |
20effc67 | 38 | # ifdef BOOST_BORLANDC |
7c673cae FG |
39 | ::detail::ignore_warnings(); |
40 | # endif | |
1e59de90 | 41 | return boost::report_errors(); |
7c673cae | 42 | } |