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
10 // <chrono>
11
12 // time_point
13
14 // template <class Clock, class Duration1, class Duration2>
15 // bool
16 // operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
17
18 // template <class Clock, class Duration1, class Duration2>
19 // bool
20 // operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
21
22 // template <class Clock, class Duration1, class Duration2>
23 // bool
24 // operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
25
26 // template <class Clock, class Duration1, class Duration2>
27 // bool
28 // operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
29
30 #include <chrono>
31 #include <cassert>
32
33 #include "test_macros.h"
34
main()35 int main()
36 {
37 typedef std::chrono::system_clock Clock;
38 typedef std::chrono::milliseconds Duration1;
39 typedef std::chrono::microseconds Duration2;
40 typedef std::chrono::time_point<Clock, Duration1> T1;
41 typedef std::chrono::time_point<Clock, Duration2> T2;
42
43 {
44 T1 t1(Duration1(3));
45 T1 t2(Duration1(3));
46 assert(!(t1 < t2));
47 assert(!(t1 > t2));
48 assert( (t1 <= t2));
49 assert( (t1 >= t2));
50 }
51 {
52 T1 t1(Duration1(3));
53 T1 t2(Duration1(4));
54 assert( (t1 < t2));
55 assert(!(t1 > t2));
56 assert( (t1 <= t2));
57 assert(!(t1 >= t2));
58 }
59 {
60 T1 t1(Duration1(3));
61 T2 t2(Duration2(3000));
62 assert(!(t1 < t2));
63 assert(!(t1 > t2));
64 assert( (t1 <= t2));
65 assert( (t1 >= t2));
66 }
67 {
68 T1 t1(Duration1(3));
69 T2 t2(Duration2(3001));
70 assert( (t1 < t2));
71 assert(!(t1 > t2));
72 assert( (t1 <= t2));
73 assert(!(t1 >= t2));
74 }
75
76 #if TEST_STD_VER > 11
77 {
78 constexpr T1 t1(Duration1(3));
79 constexpr T1 t2(Duration1(3));
80 static_assert(!(t1 < t2), "");
81 static_assert(!(t1 > t2), "");
82 static_assert( (t1 <= t2), "");
83 static_assert( (t1 >= t2), "");
84 }
85 {
86 constexpr T1 t1(Duration1(3));
87 constexpr T1 t2(Duration1(4));
88 static_assert( (t1 < t2), "");
89 static_assert(!(t1 > t2), "");
90 static_assert( (t1 <= t2), "");
91 static_assert(!(t1 >= t2), "");
92 }
93 {
94 constexpr T1 t1(Duration1(3));
95 constexpr T2 t2(Duration2(3000));
96 static_assert(!(t1 < t2), "");
97 static_assert(!(t1 > t2), "");
98 static_assert( (t1 <= t2), "");
99 static_assert( (t1 >= t2), "");
100 }
101 {
102 constexpr T1 t1(Duration1(3));
103 constexpr T2 t2(Duration2(3001));
104 static_assert( (t1 < t2), "");
105 static_assert(!(t1 > t2), "");
106 static_assert( (t1 <= t2), "");
107 static_assert(!(t1 >= t2), "");
108 }
109 #endif
110 }
111