constructor_pass.cpp 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. #include <boost/chrono/chrono.hpp>
  14. #include <boost/detail/lightweight_test.hpp>
  15. #include "../rep.h"
  16. #ifdef BOOST_NO_CXX11_CONSTEXPR
  17. #define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
  18. #else
  19. #include <boost/static_assert.hpp>
  20. #define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
  21. #endif
  22. int main()
  23. {
  24. {
  25. typedef boost::chrono::system_clock Clock;
  26. typedef boost::chrono::microseconds Duration1;
  27. typedef boost::chrono::milliseconds Duration2;
  28. boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
  29. boost::chrono::time_point<Clock, Duration1> t1 = t2;
  30. BOOST_TEST(t1.time_since_epoch() == Duration1(3000));
  31. }
  32. {
  33. typedef boost::chrono::system_clock Clock;
  34. typedef boost::chrono::microseconds Duration1;
  35. typedef boost::chrono::milliseconds Duration2;
  36. BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration2> t2(Duration2(3));
  37. BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration1> t1 = t2;
  38. BOOST_CONSTEXPR_ASSERT(t1.time_since_epoch() == Duration1(3000));
  39. }
  40. {
  41. typedef boost::chrono::system_clock Clock;
  42. typedef boost::chrono::duration<Rep, boost::milli> Duration;
  43. boost::chrono::time_point<Clock, Duration> t;
  44. BOOST_TEST(t.time_since_epoch() == Duration::zero());
  45. }
  46. {
  47. typedef boost::chrono::system_clock Clock;
  48. typedef boost::chrono::duration<Rep, boost::milli> Duration;
  49. BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t;
  50. BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration::zero());
  51. }
  52. {
  53. typedef boost::chrono::system_clock Clock;
  54. typedef boost::chrono::milliseconds Duration;
  55. boost::chrono::time_point<Clock, Duration> t(Duration(3));
  56. BOOST_TEST(t.time_since_epoch() == Duration(3));
  57. }
  58. {
  59. typedef boost::chrono::system_clock Clock;
  60. typedef boost::chrono::milliseconds Duration;
  61. BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(Duration(3));
  62. BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3));
  63. }
  64. {
  65. typedef boost::chrono::system_clock Clock;
  66. typedef boost::chrono::milliseconds Duration;
  67. boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
  68. BOOST_TEST(t.time_since_epoch() == Duration(3000));
  69. }
  70. {
  71. typedef boost::chrono::system_clock Clock;
  72. typedef boost::chrono::milliseconds Duration;
  73. BOOST_CONSTEXPR boost::chrono::time_point<Clock, Duration> t(boost::chrono::seconds(3));
  74. BOOST_CONSTEXPR_ASSERT(t.time_since_epoch() == Duration(3000));
  75. }
  76. return boost::report_errors();
  77. }