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 14 #include <boost/chrono/chrono.hpp> 15 #include <boost/detail/lightweight_test.hpp> 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 23 main()24int main() 25 { 26 typedef boost::chrono::system_clock Clock; 27 typedef boost::chrono::milliseconds Duration1; 28 typedef boost::chrono::microseconds Duration2; 29 typedef boost::chrono::time_point<Clock, Duration1> T1; 30 typedef boost::chrono::time_point<Clock, Duration2> T2; 31 32 { 33 T1 t1(Duration1(3)); 34 T1 t2(Duration1(3)); 35 BOOST_TEST( (t1 == t2)); 36 BOOST_TEST(! (t1 != t2)); 37 } 38 { 39 BOOST_CONSTEXPR T1 t1(Duration1(3)); 40 BOOST_CONSTEXPR T1 t2(Duration1(3)); 41 BOOST_CONSTEXPR_ASSERT( (t1 == t2)); 42 BOOST_CONSTEXPR_ASSERT(! (t1 != t2)); 43 } 44 { 45 T1 t1(Duration1(3)); 46 T1 t2(Duration1(4)); 47 BOOST_TEST(! (t1 == t2)); 48 BOOST_TEST( (t1 != t2)); 49 } 50 { 51 BOOST_CONSTEXPR T1 t1(Duration1(3)); 52 BOOST_CONSTEXPR T1 t2(Duration1(4)); 53 BOOST_CONSTEXPR_ASSERT(! (t1 == t2)); 54 BOOST_CONSTEXPR_ASSERT( (t1 != t2)); 55 } 56 { 57 T1 t1(Duration1(3)); 58 T2 t2(Duration2(3000)); 59 BOOST_TEST( (t1 == t2)); 60 BOOST_TEST(! (t1 != t2)); 61 } 62 { 63 BOOST_CONSTEXPR T1 t1(Duration1(3)); 64 BOOST_CONSTEXPR T2 t2(Duration2(3000)); 65 BOOST_CONSTEXPR_ASSERT( (t1 == t2)); 66 BOOST_CONSTEXPR_ASSERT(! (t1 != t2)); 67 } 68 { 69 T1 t1(Duration1(3)); 70 T2 t2(Duration2(3001)); 71 BOOST_TEST(! (t1 == t2)); 72 BOOST_TEST( (t1 != t2)); 73 } 74 { 75 BOOST_CONSTEXPR T1 t1(Duration1(3)); 76 BOOST_CONSTEXPR T2 t2(Duration2(3001)); 77 BOOST_CONSTEXPR_ASSERT(! (t1 == t2)); 78 BOOST_CONSTEXPR_ASSERT( (t1 != t2)); 79 } 80 { 81 T1 t1(Duration1(3)); 82 T1 t2(Duration1(3)); 83 BOOST_TEST(! (t1 < t2)); 84 BOOST_TEST(! (t1 > t2)); 85 BOOST_TEST( (t1 <= t2)); 86 BOOST_TEST( (t1 >= t2)); 87 } 88 { 89 BOOST_CONSTEXPR T1 t1(Duration1(3)); 90 BOOST_CONSTEXPR T1 t2(Duration1(3)); 91 BOOST_CONSTEXPR_ASSERT(! (t1 < t2)); 92 BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); 93 BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); 94 BOOST_CONSTEXPR_ASSERT( (t1 >= t2)); 95 } 96 { 97 T1 t1(Duration1(3)); 98 T1 t2(Duration1(4)); 99 BOOST_TEST( (t1 < t2)); 100 BOOST_TEST(! (t1 > t2)); 101 BOOST_TEST( (t1 <= t2)); 102 BOOST_TEST(! (t1 >= t2)); 103 } 104 { 105 BOOST_CONSTEXPR T1 t1(Duration1(3)); 106 BOOST_CONSTEXPR T1 t2(Duration1(4)); 107 BOOST_CONSTEXPR_ASSERT( (t1 < t2)); 108 BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); 109 BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); 110 BOOST_CONSTEXPR_ASSERT(! (t1 >= t2)); 111 } 112 { 113 T1 t1(Duration1(3)); 114 T2 t2(Duration2(3000)); 115 BOOST_TEST(! (t1 < t2)); 116 BOOST_TEST(! (t1 > t2)); 117 BOOST_TEST( (t1 <= t2)); 118 BOOST_TEST( (t1 >= t2)); 119 } 120 { 121 BOOST_CONSTEXPR T1 t1(Duration1(3)); 122 BOOST_CONSTEXPR T2 t2(Duration2(3000)); 123 BOOST_CONSTEXPR_ASSERT(! (t1 < t2)); 124 BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); 125 BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); 126 BOOST_CONSTEXPR_ASSERT( (t1 >= t2)); 127 } 128 { 129 T1 t1(Duration1(3)); 130 T2 t2(Duration2(3001)); 131 BOOST_TEST( (t1 < t2)); 132 BOOST_TEST(! (t1 > t2)); 133 BOOST_TEST( (t1 <= t2)); 134 BOOST_TEST(! (t1 >= t2)); 135 } 136 { 137 BOOST_CONSTEXPR T1 t1(Duration1(3)); 138 BOOST_CONSTEXPR T2 t2(Duration2(3001)); 139 BOOST_CONSTEXPR_ASSERT( (t1 < t2)); 140 BOOST_CONSTEXPR_ASSERT(! (t1 > t2)); 141 BOOST_CONSTEXPR_ASSERT( (t1 <= t2)); 142 BOOST_CONSTEXPR_ASSERT(! (t1 >= t2)); 143 } 144 145 return boost::report_errors(); 146 } 147