[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.operators / year_month_day.pass.cpp
blob742207dbdbc6335603e1cfeb0b05074c5458b0a6
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // <chrono>
11 // class year_month_day;
13 // constexpr year_month_day
14 // operator/(const year_month& ym, const day& d) noexcept;
15 // Returns: {ym.year(), ym.month(), d}.
17 // constexpr year_month_day
18 // operator/(const year_month& ym, int d) noexcept;
19 // Returns: ym / day(d).
21 // constexpr year_month_day
22 // operator/(const year& y, const month_day& md) noexcept;
23 // Returns: y / md.month() / md.day().
25 // constexpr year_month_day
26 // operator/(int y, const month_day& md) noexcept;
27 // Returns: year(y) / md.
29 // constexpr year_month_day
30 // operator/(const month_day& md, const year& y) noexcept;
31 // Returns: y / md.
33 // constexpr year_month_day
34 // operator/(const month_day& md, int y) noexcept;
35 // Returns: year(y) / md.
37 #include <chrono>
38 #include <type_traits>
39 #include <cassert>
41 #include "test_macros.h"
43 int main(int, char**)
45 using year = std::chrono::year;
46 using month = std::chrono::month;
47 using day = std::chrono::day;
48 using year_month = std::chrono::year_month;
49 using month_day = std::chrono::month_day;
50 using year_month_day = std::chrono::year_month_day;
52 constexpr month February = std::chrono::February;
53 constexpr year_month Feb2018{year{2018}, February};
55 { // operator/(const year_month& ym, const day& d)
56 ASSERT_NOEXCEPT ( Feb2018/day{2});
57 ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/day{2}));
59 static_assert((Feb2018/day{2}).month() == February, "");
60 static_assert((Feb2018/day{2}).day() == day{2}, "");
62 for (int i = 1000; i < 1010; ++i)
63 for (int j = 1; j <= 12; ++j)
64 for (unsigned k = 0; k <= 28; ++k)
66 year y(i);
67 month m(j);
68 day d(k);
69 year_month ym(y, m);
70 year_month_day ymd = ym/d;
71 assert(ymd.year() == y);
72 assert(ymd.month() == m);
73 assert(ymd.day() == d);
78 { // operator/(const year_month& ym, int d)
79 ASSERT_NOEXCEPT ( Feb2018/2);
80 ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
82 static_assert((Feb2018/2).month() == February, "");
83 static_assert((Feb2018/2).day() == day{2}, "");
85 for (int i = 1000; i < 1010; ++i)
86 for (int j = 1; j <= 12; ++j)
87 for (unsigned k = 0; k <= 28; ++k)
89 year y(i);
90 month m(j);
91 day d(k);
92 year_month ym(y, m);
93 year_month_day ymd = ym/k;
94 assert(ymd.year() == y);
95 assert(ymd.month() == m);
96 assert(ymd.day() == d);
101 { // operator/(const year_month& ym, int d)
102 ASSERT_NOEXCEPT ( Feb2018/2);
103 ASSERT_SAME_TYPE(year_month_day, decltype(Feb2018/2));
105 static_assert((Feb2018/2).month() == February, "");
106 static_assert((Feb2018/2).day() == day{2}, "");
108 for (int i = 1000; i < 1010; ++i)
109 for (int j = 1; j <= 12; ++j)
110 for (unsigned k = 0; k <= 28; ++k)
112 year y(i);
113 month m(j);
114 day d(k);
115 year_month ym(y, m);
116 year_month_day ymd = ym/k;
117 assert(ymd.year() == y);
118 assert(ymd.month() == m);
119 assert(ymd.day() == d);
126 { // operator/(const year& y, const month_day& md) (and switched)
127 ASSERT_NOEXCEPT ( year{2018}/month_day{February, day{2}});
128 ASSERT_SAME_TYPE(year_month_day, decltype(year{2018}/month_day{February, day{2}}));
129 ASSERT_NOEXCEPT ( month_day{February, day{2}}/year{2018});
130 ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/year{2018}));
132 static_assert((year{2018}/month_day{February, day{2}}).month() == February, "" );
133 static_assert((year{2018}/month_day{February, day{2}}).day() == day{2}, "" );
134 static_assert((month_day{February, day{2}}/year{2018}).month() == February, "" );
135 static_assert((month_day{February, day{2}}/year{2018}).day() == day{2}, "" );
137 for (int i = 1000; i < 1010; ++i)
138 for (int j = 1; j <= 12; ++j)
139 for (unsigned k = 0; k <= 28; ++k)
141 year y(i);
142 month m(j);
143 day d(k);
144 month_day md(m, d);
145 year_month_day ymd1 = y/md;
146 year_month_day ymd2 = md/y;
147 assert(ymd1.year() == y);
148 assert(ymd2.year() == y);
149 assert(ymd1.month() == m);
150 assert(ymd2.month() == m);
151 assert(ymd1.day() == d);
152 assert(ymd2.day() == d);
153 assert(ymd1 == ymd2);
157 { // operator/(const month_day& md, int y) (and switched)
158 ASSERT_NOEXCEPT ( 2018/month_day{February, day{2}});
159 ASSERT_SAME_TYPE(year_month_day, decltype(2018/month_day{February, day{2}}));
160 ASSERT_NOEXCEPT ( month_day{February, day{2}}/2018);
161 ASSERT_SAME_TYPE(year_month_day, decltype(month_day{February, day{2}}/2018));
163 static_assert((2018/month_day{February, day{2}}).month() == February, "" );
164 static_assert((2018/month_day{February, day{2}}).day() == day{2}, "" );
165 static_assert((month_day{February, day{2}}/2018).month() == February, "" );
166 static_assert((month_day{February, day{2}}/2018).day() == day{2}, "" );
168 for (int i = 1000; i < 1010; ++i)
169 for (int j = 1; j <= 12; ++j)
170 for (unsigned k = 0; k <= 28; ++k)
172 year y(i);
173 month m(j);
174 day d(k);
175 month_day md(m, d);
176 year_month_day ymd1 = i/md;
177 year_month_day ymd2 = md/i;
178 assert(ymd1.year() == y);
179 assert(ymd2.year() == y);
180 assert(ymd1.month() == m);
181 assert(ymd2.month() == m);
182 assert(ymd1.day() == d);
183 assert(ymd2.day() == d);
184 assert(ymd1 == ymd2);
189 return 0;