test_0F1.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_0F1.hpp"
  6. #include <boost/multiprecision/cpp_bin_float.hpp>
  7. #include <boost/multiprecision/cpp_dec_float.hpp>
  8. void expected_results()
  9. {
  10. //
  11. // Define the max and mean errors expected for
  12. // various compilers and platforms.
  13. //
  14. const char* largest_type;
  15. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  16. if(boost::math::policies::digits<double, boost::math::policies::policy<> >() == boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  17. {
  18. largest_type = "(long\\s+)?double|real_concept|cpp_bin_float_quad|dec_40";
  19. }
  20. else
  21. {
  22. largest_type = "long double|real_concept|cpp_bin_float_quad|dec_40";
  23. }
  24. #else
  25. largest_type = "(long\\s+)?double|cpp_bin_float_quad|dec_40";
  26. #endif
  27. add_expected_result(
  28. ".*", // compiler
  29. ".*", // stdlib
  30. ".*", // platform
  31. largest_type, // test type(s)
  32. "Integer.*", // test data group
  33. ".*", 300, 100); // test function
  34. add_expected_result(
  35. ".*", // compiler
  36. ".*", // stdlib
  37. ".*", // platform
  38. largest_type, // test type(s)
  39. "Real.*", // test data group
  40. ".*", 2000, 1000); // test function
  41. add_expected_result(
  42. ".*", // compiler
  43. ".*", // stdlib
  44. ".*", // platform
  45. largest_type, // test type(s)
  46. "Large.*", // test data group
  47. ".*", 400, 100); // test function
  48. //
  49. // Finish off by printing out the compiler/stdlib/platform names,
  50. // we do this to make it easier to mark up expected error rates.
  51. //
  52. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  53. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  54. }
  55. BOOST_AUTO_TEST_CASE( test_main )
  56. {
  57. expected_results();
  58. BOOST_MATH_CONTROL_FP;
  59. #if !defined(TEST) || (TEST == 1)
  60. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  61. test_spots(0.0F, "float");
  62. #endif
  63. test_spots(0.0, "double");
  64. #endif
  65. #if !defined(TEST) || (TEST == 2)
  66. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  67. test_spots(0.0L, "long double");
  68. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  69. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  70. #endif
  71. #endif
  72. #endif
  73. #if !defined(TEST) || (TEST == 3)
  74. test_spots(boost::multiprecision::cpp_bin_float_quad(), "cpp_bin_float_quad");
  75. #endif
  76. #if !defined(TEST) || (TEST == 4)
  77. typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<40> > dec_40;
  78. test_spots(dec_40(), "dec_40");
  79. #endif
  80. }