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 // duration
13 
14 // template <class Rep1, class Period1, class Rep2, class Period2>
15 //   constexpr
16 //   bool
17 //   operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
18 
19 // template <class Rep1, class Period1, class Rep2, class Period2>
20 //   constexpr
21 //   bool
22 //   operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
23 
24 // template <class Rep1, class Period1, class Rep2, class Period2>
25 //   constexpr
26 //   bool
27 //   operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
28 
29 // template <class Rep1, class Period1, class Rep2, class Period2>
30 //   constexpr
31 //   bool
32 //   operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
33 
34 #include <chrono>
35 #include <cassert>
36 
main()37 int main()
38 {
39     {
40     std::chrono::seconds s1(3);
41     std::chrono::seconds s2(3);
42     assert(!(s1 < s2));
43     assert(!(s1 > s2));
44     assert( (s1 <= s2));
45     assert( (s1 >= s2));
46     }
47     {
48     std::chrono::seconds s1(3);
49     std::chrono::seconds s2(4);
50     assert( (s1 < s2));
51     assert(!(s1 > s2));
52     assert( (s1 <= s2));
53     assert(!(s1 >= s2));
54     }
55     {
56     std::chrono::milliseconds s1(3);
57     std::chrono::microseconds s2(3000);
58     assert(!(s1 < s2));
59     assert(!(s1 > s2));
60     assert( (s1 <= s2));
61     assert( (s1 >= s2));
62     }
63     {
64     std::chrono::milliseconds s1(3);
65     std::chrono::microseconds s2(4000);
66     assert( (s1 < s2));
67     assert(!(s1 > s2));
68     assert( (s1 <= s2));
69     assert(!(s1 >= s2));
70     }
71     {
72     std::chrono::duration<int, std::ratio<2, 3> > s1(9);
73     std::chrono::duration<int, std::ratio<3, 5> > s2(10);
74     assert(!(s1 < s2));
75     assert(!(s1 > s2));
76     assert( (s1 <= s2));
77     assert( (s1 >= s2));
78     }
79     {
80     std::chrono::duration<int, std::ratio<2, 3> > s1(10);
81     std::chrono::duration<int, std::ratio<3, 5> > s2(9);
82     assert(!(s1 < s2));
83     assert( (s1 > s2));
84     assert(!(s1 <= s2));
85     assert( (s1 >= s2));
86     }
87     {
88     std::chrono::duration<int, std::ratio<2, 3> > s1(9);
89     std::chrono::duration<double, std::ratio<3, 5> > s2(10);
90     assert(!(s1 < s2));
91     assert(!(s1 > s2));
92     assert( (s1 <= s2));
93     assert( (s1 >= s2));
94     }
95 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
96     {
97     constexpr std::chrono::seconds s1(3);
98     constexpr std::chrono::seconds s2(3);
99     static_assert(!(s1 < s2), "");
100     static_assert(!(s1 > s2), "");
101     static_assert( (s1 <= s2), "");
102     static_assert( (s1 >= s2), "");
103     }
104     {
105     constexpr std::chrono::seconds s1(3);
106     constexpr std::chrono::seconds s2(4);
107     static_assert( (s1 < s2), "");
108     static_assert(!(s1 > s2), "");
109     static_assert( (s1 <= s2), "");
110     static_assert(!(s1 >= s2), "");
111     }
112     {
113     constexpr std::chrono::milliseconds s1(3);
114     constexpr std::chrono::microseconds s2(3000);
115     static_assert(!(s1 < s2), "");
116     static_assert(!(s1 > s2), "");
117     static_assert( (s1 <= s2), "");
118     static_assert( (s1 >= s2), "");
119     }
120     {
121     constexpr std::chrono::milliseconds s1(3);
122     constexpr std::chrono::microseconds s2(4000);
123     static_assert( (s1 < s2), "");
124     static_assert(!(s1 > s2), "");
125     static_assert( (s1 <= s2), "");
126     static_assert(!(s1 >= s2), "");
127     }
128     {
129     constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
130     constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
131     static_assert(!(s1 < s2), "");
132     static_assert(!(s1 > s2), "");
133     static_assert( (s1 <= s2), "");
134     static_assert( (s1 >= s2), "");
135     }
136     {
137     constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
138     constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
139     static_assert(!(s1 < s2), "");
140     static_assert( (s1 > s2), "");
141     static_assert(!(s1 <= s2), "");
142     static_assert( (s1 >= s2), "");
143     }
144     {
145     constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
146     constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
147     static_assert(!(s1 < s2), "");
148     static_assert(!(s1 > s2), "");
149     static_assert( (s1 <= s2), "");
150     static_assert( (s1 >= s2), "");
151     }
152 #endif
153 }
154