pow.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <boost/numeric/interval.hpp>
  11. #include <boost/test/minimal.hpp>
  12. #include "bugs.hpp"
  13. bool test_pow(double al, double au, double bl, double bu, int p) {
  14. typedef boost::numeric::interval<double> I;
  15. I b = pow(I(al, au), p);
  16. return b.lower() == bl && b.upper() == bu;
  17. }
  18. int test_main(int, char *[]) {
  19. BOOST_CHECK(test_pow(2, 3, 8, 27, 3));
  20. BOOST_CHECK(test_pow(2, 3, 16, 81, 4));
  21. BOOST_CHECK(test_pow(-3, 2, -27, 8, 3));
  22. BOOST_CHECK(test_pow(-3, 2, 0, 81, 4));
  23. BOOST_CHECK(test_pow(-3, -2, -27, -8, 3));
  24. BOOST_CHECK(test_pow(-3, -2, 16, 81, 4));
  25. BOOST_CHECK(test_pow(2, 4, 1./64, 1./8, -3));
  26. BOOST_CHECK(test_pow(2, 4, 1./256, 1./16, -4));
  27. BOOST_CHECK(test_pow(-4, -2, -1./8, -1./64, -3));
  28. BOOST_CHECK(test_pow(-4, -2, 1./256, 1./16, -4));
  29. BOOST_CHECK(test_pow(2, 3, 1, 1, 0));
  30. BOOST_CHECK(test_pow(-3, 2, 1, 1, 0));
  31. BOOST_CHECK(test_pow(-3, -2, 1, 1, 0));
  32. # ifdef __BORLANDC__
  33. ::detail::ignore_warnings();
  34. # endif
  35. return 0;
  36. }