1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <chrono> 10 11 // time_point 12 13 // template <class Clock, class Duration1, class Duration2> 14 // bool 15 // operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 16 17 // template <class Clock, class Duration1, class Duration2> 18 // bool 19 // operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 20 21 // template <class Clock, class Duration1, class Duration2> 22 // bool 23 // operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 24 25 // template <class Clock, class Duration1, class Duration2> 26 // bool 27 // operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 28 29 #include <chrono> 30 #include <cassert> 31 32 #include "test_macros.h" 33 34 int main(int, char**) 35 { 36 typedef std::chrono::system_clock Clock; 37 typedef std::chrono::milliseconds Duration1; 38 typedef std::chrono::microseconds Duration2; 39 typedef std::chrono::time_point<Clock, Duration1> T1; 40 typedef std::chrono::time_point<Clock, Duration2> T2; 41 42 { 43 T1 t1(Duration1(3)); 44 T1 t2(Duration1(3)); 45 assert(!(t1 < t2)); 46 assert(!(t1 > t2)); 47 assert( (t1 <= t2)); 48 assert( (t1 >= t2)); 49 } 50 { 51 T1 t1(Duration1(3)); 52 T1 t2(Duration1(4)); 53 assert( (t1 < t2)); 54 assert(!(t1 > t2)); 55 assert( (t1 <= t2)); 56 assert(!(t1 >= t2)); 57 } 58 { 59 T1 t1(Duration1(3)); 60 T2 t2(Duration2(3000)); 61 assert(!(t1 < t2)); 62 assert(!(t1 > t2)); 63 assert( (t1 <= t2)); 64 assert( (t1 >= t2)); 65 } 66 { 67 T1 t1(Duration1(3)); 68 T2 t2(Duration2(3001)); 69 assert( (t1 < t2)); 70 assert(!(t1 > t2)); 71 assert( (t1 <= t2)); 72 assert(!(t1 >= t2)); 73 } 74 75 #if TEST_STD_VER > 11 76 { 77 constexpr T1 t1(Duration1(3)); 78 constexpr T1 t2(Duration1(3)); 79 static_assert(!(t1 < t2), ""); 80 static_assert(!(t1 > t2), ""); 81 static_assert( (t1 <= t2), ""); 82 static_assert( (t1 >= t2), ""); 83 } 84 { 85 constexpr T1 t1(Duration1(3)); 86 constexpr T1 t2(Duration1(4)); 87 static_assert( (t1 < t2), ""); 88 static_assert(!(t1 > t2), ""); 89 static_assert( (t1 <= t2), ""); 90 static_assert(!(t1 >= t2), ""); 91 } 92 { 93 constexpr T1 t1(Duration1(3)); 94 constexpr T2 t2(Duration2(3000)); 95 static_assert(!(t1 < t2), ""); 96 static_assert(!(t1 > t2), ""); 97 static_assert( (t1 <= t2), ""); 98 static_assert( (t1 >= t2), ""); 99 } 100 { 101 constexpr T1 t1(Duration1(3)); 102 constexpr T2 t2(Duration2(3001)); 103 static_assert( (t1 < t2), ""); 104 static_assert(!(t1 > t2), ""); 105 static_assert( (t1 <= t2), ""); 106 static_assert(!(t1 >= t2), ""); 107 } 108 #endif 109 110 return 0; 111 } 112