ratio_divide_pass.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_divide
  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. typedef boost::ratio_divide<R1, R2> R;
  24. BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
  25. }
  26. {
  27. typedef boost::ratio<1, 2> R1;
  28. typedef boost::ratio<1, 1> R2;
  29. typedef boost::ratio_divide<R1, R2> R;
  30. BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
  31. }
  32. {
  33. typedef boost::ratio<-1, 2> R1;
  34. typedef boost::ratio<1, 1> R2;
  35. typedef boost::ratio_divide<R1, R2> R;
  36. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  37. }
  38. {
  39. typedef boost::ratio<1, -2> R1;
  40. typedef boost::ratio<1, 1> R2;
  41. typedef boost::ratio_divide<R1, R2> R;
  42. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  43. }
  44. {
  45. typedef boost::ratio<1, 2> R1;
  46. typedef boost::ratio<-1, 1> R2;
  47. typedef boost::ratio_divide<R1, R2> R;
  48. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  49. }
  50. {
  51. typedef boost::ratio<1, 2> R1;
  52. typedef boost::ratio<1, -1> R2;
  53. typedef boost::ratio_divide<R1, R2> R;
  54. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  55. }
  56. {
  57. typedef boost::ratio<56987354, 467584654> R1;
  58. typedef boost::ratio<544668, 22145> R2;
  59. typedef boost::ratio_divide<R1, R2> R;
  60. BOOST_RATIO_STATIC_ASSERT(R::num == 630992477165LL && R::den == 127339199162436LL, NOTHING, ());
  61. }
  62. }