ratio_equal_pass.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // Adaptation to Boost of the libcxx
  10. // Copyright 2010 Vicente J. Botet Escriba
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See http://www.boost.org/LICENSE_1_0.txt
  13. // test ratio_equal
  14. #include <boost/ratio/ratio.hpp>
  15. #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
  16. #define NOTHING ""
  17. #endif
  18. void test()
  19. {
  20. {
  21. typedef boost::ratio<1, 1> R1;
  22. typedef boost::ratio<1, 1> R2;
  23. BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
  24. }
  25. {
  26. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  27. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  28. BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
  29. }
  30. {
  31. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  32. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  33. BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
  34. }
  35. {
  36. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
  37. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
  38. BOOST_RATIO_STATIC_ASSERT((boost::ratio_equal<R1, R2>::value), NOTHING, ());
  39. }
  40. {
  41. typedef boost::ratio<1, 1> R1;
  42. typedef boost::ratio<1, -1> R2;
  43. BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
  44. }
  45. {
  46. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  47. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  48. BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
  49. }
  50. {
  51. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  52. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  53. BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
  54. }
  55. {
  56. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
  57. typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
  58. BOOST_RATIO_STATIC_ASSERT((!boost::ratio_equal<R1, R2>::value), NOTHING, ());
  59. }
  60. }