test_2F0.cpp 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_2F0.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. if (boost::math::policies::digits<double, boost::math::policies::policy<> >() != boost::math::policies::digits<long double, boost::math::policies::policy<> >())
  28. {
  29. add_expected_result(
  30. ".*", // compiler
  31. ".*", // stdlib
  32. ".*", // platform
  33. "double", // test type(s)
  34. "Random non-integer a2.*", // test data group
  35. ".*", 10, 5); // test function
  36. add_expected_result(
  37. ".*", // compiler
  38. ".*", // stdlib
  39. ".*", // platform
  40. "double", // test type(s)
  41. "a1 = a2 \\+ 0\\.5", // test data group
  42. ".*", 10, 5); // test function
  43. }
  44. add_expected_result(
  45. ".*", // compiler
  46. ".*", // stdlib
  47. ".*", // platform
  48. largest_type, // test type(s)
  49. "Random non-integer a2.*", // test data group
  50. ".*", 9000, 3000); // test function
  51. add_expected_result(
  52. ".*", // compiler
  53. ".*", // stdlib
  54. ".*", // platform
  55. largest_type, // test type(s)
  56. "Integer.*", // test data group
  57. ".*", 300, 100); // test function
  58. add_expected_result(
  59. ".*", // compiler
  60. ".*", // stdlib
  61. ".*", // platform
  62. largest_type, // test type(s)
  63. "a1 = a2 \\+ 0\\.5", // test data group
  64. ".*", 2000, 200); // test function
  65. //
  66. // Finish off by printing out the compiler/stdlib/platform names,
  67. // we do this to make it easier to mark up expected error rates.
  68. //
  69. std::cout << "Tests run with " << BOOST_COMPILER << ", "
  70. << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
  71. }
  72. BOOST_AUTO_TEST_CASE( test_main )
  73. {
  74. typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<40> > dec_40;
  75. expected_results();
  76. BOOST_MATH_CONTROL_FP;
  77. #ifndef BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
  78. test_spots(0.0F, "float");
  79. #endif
  80. test_spots(0.0, "double");
  81. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  82. test_spots(0.0L, "long double");
  83. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  84. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  85. #endif
  86. #endif
  87. test_spots(boost::multiprecision::cpp_bin_float_quad(), "cpp_bin_float_quad");
  88. test_spots(dec_40(), "dec_40");
  89. }