test_rationals.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 <boost/math/concepts/real_concept.hpp>
  6. #define BOOST_TEST_MAIN
  7. #include <boost/test/unit_test.hpp>
  8. #include <boost/test/tools/floating_point_comparison.hpp>
  9. #include <boost/array.hpp>
  10. #include <boost/math/tools/rational.hpp>
  11. #include <iostream>
  12. template <class T, class U>
  13. void do_test_spots(T, U);
  14. template <class T>
  15. void test_spots(T t, const char* n)
  16. {
  17. std::cout << "Testing basic sanity checks for type " << n << std::endl;
  18. do_test_spots(t, int(0));
  19. do_test_spots(t, unsigned(0));
  20. #ifdef BOOST_HAS_LONG_LONG
  21. do_test_spots(t, (boost::ulong_long_type)(0));
  22. #endif
  23. do_test_spots(t, float(0));
  24. do_test_spots(t, T(0));
  25. }
  26. BOOST_AUTO_TEST_CASE( test_main )
  27. {
  28. test_spots(0.0F, "float");
  29. test_spots(0.0, "double");
  30. #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  31. test_spots(0.0L, "long double");
  32. #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
  33. test_spots(boost::math::concepts::real_concept(0.1), "real_concept");
  34. #endif
  35. #else
  36. std::cout << "<note>The long double tests have been disabled on this platform "
  37. "either because the long double overloads of the usual math functions are "
  38. "not available at all, or because they are too inaccurate for these tests "
  39. "to pass.</note>" << std::endl;
  40. #endif
  41. }