| 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> |
|---|
| 12 | #include <boost/test/minimal.hpp> |
|---|
| 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 | |
|---|
| 21 | int test_main(int, char *[]) { |
|---|
| 22 | BOOST_CHECK(test_pow(2, 3, 8, 27, 3)); |
|---|
| 23 | BOOST_CHECK(test_pow(2, 3, 16, 81, 4)); |
|---|
| 24 | BOOST_CHECK(test_pow(-3, 2, -27, 8, 3)); |
|---|
| 25 | BOOST_CHECK(test_pow(-3, 2, 0, 81, 4)); |
|---|
| 26 | BOOST_CHECK(test_pow(-3, -2, -27, -8, 3)); |
|---|
| 27 | BOOST_CHECK(test_pow(-3, -2, 16, 81, 4)); |
|---|
| 28 | |
|---|
| 29 | BOOST_CHECK(test_pow(2, 4, 1./64, 1./8, -3)); |
|---|
| 30 | BOOST_CHECK(test_pow(2, 4, 1./256, 1./16, -4)); |
|---|
| 31 | BOOST_CHECK(test_pow(-4, -2, -1./8, -1./64, -3)); |
|---|
| 32 | BOOST_CHECK(test_pow(-4, -2, 1./256, 1./16, -4)); |
|---|
| 33 | |
|---|
| 34 | BOOST_CHECK(test_pow(2, 3, 1, 1, 0)); |
|---|
| 35 | BOOST_CHECK(test_pow(-3, 2, 1, 1, 0)); |
|---|
| 36 | BOOST_CHECK(test_pow(-3, -2, 1, 1, 0)); |
|---|
| 37 | |
|---|
| 38 | # ifdef __BORLANDC__ |
|---|
| 39 | ::detail::ignore_warnings(); |
|---|
| 40 | # endif |
|---|
| 41 | return 0; |
|---|
| 42 | } |
|---|