test_gamma.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // (C) Copyright John Maddock 2006.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #include "test_gamma.hpp"
  6. #ifdef TEST_MPFR
  7. #include <boost/multiprecision/mpfr.hpp>
  8. #else
  9. #include <boost/multiprecision/cpp_bin_float.hpp>
  10. #endif
  11. void expected_results()
  12. {
  13. //
  14. // Define the max and mean errors expected for
  15. // various compilers and platforms.
  16. //
  17. const char* largest_type;
  18. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  19. if (boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  20. {
  21. largest_type = "(long\\s+)?double";
  22. }
  23. else
  24. {
  25. largest_type = "long double";
  26. }
  27. #else
  28. largest_type = "(long\\s+)?double";
  29. #endif
  30. add_expected_result(
  31. ".*", // compiler
  32. ".*", // stdlib
  33. ".*", // platform
  34. ".*", // test type(s)
  35. ".*near 1.*", // test data group
  36. ".*lgamma.*", 100000000000LL, 100000000000LL); // test function
  37. add_expected_result(
  38. ".*", // compiler
  39. ".*", // stdlib
  40. ".*", // platform
  41. ".*", // test type(s)
  42. ".*near 0.*", // test data group
  43. ".*lgamma.*", 300000, 100000); // test function
  44. add_expected_result(
  45. ".*", // compiler
  46. ".*", // stdlib
  47. ".*", // platform
  48. ".*", // test type(s)
  49. ".*", // test data group
  50. ".*", 110000, 50000); // test function
  51. //
  52. // Finish off by printing out the compiler/stdlib/platform names,
  53. // we do this to make it easier to mark up expected error rates.
  54. //
  55. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  56. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  57. }
  58. BOOST_AUTO_TEST_CASE(test_main)
  59. {
  60. expected_results();
  61. BOOST_MATH_CONTROL_FP;
  62. #ifdef TEST_MPFR
  63. typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<450> > mp_type;
  64. const char* name = "number<mpfr_float_backend<450> >";
  65. #else
  66. typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<450> > mp_type;
  67. const char* name = "number<cpp_bin_float<450> >";
  68. #endif
  69. test_gamma(mp_type(0), name);
  70. }