[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_weekday.pass.cpp
blob59d3875287431c5911d87688045b8f4f47edc2cf
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_weekday;
13 // constexpr year_month_weekday
14 // operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
15 // Returns: {ym.year(), ym.month(), wdi}.
17 // constexpr year_month_weekday
18 // operator/(const year& y, const month_weekday& mwd) noexcept;
19 // Returns: {y, mwd.month(), mwd.weekday_indexed()}.
21 // constexpr year_month_weekday
22 // operator/(int y, const month_weekday& mwd) noexcept;
23 // Returns: year(y) / mwd.
25 // constexpr year_month_weekday
26 // operator/(const month_weekday& mwd, const year& y) noexcept;
27 // Returns: y / mwd.
29 // constexpr year_month_weekday
30 // operator/(const month_weekday& mwd, int y) noexcept;
31 // Returns: year(y) / mwd.
33 #include <chrono>
34 #include <type_traits>
35 #include <cassert>
37 #include "test_macros.h"
39 int main(int, char**)
41 using year = std::chrono::year;
42 using year_month = std::chrono::year_month;
43 using month_weekday = std::chrono::month_weekday;
44 using year_month_weekday = std::chrono::year_month_weekday;
45 using month = std::chrono::month;
46 using weekday = std::chrono::weekday;
47 using weekday = std::chrono::weekday;
48 using weekday_indexed = std::chrono::weekday_indexed;
50 constexpr weekday Tuesday = std::chrono::Tuesday;
51 constexpr month February = std::chrono::February;
54 { // operator/(const year_month& ym, const weekday_indexed& wdi)
55 constexpr year_month Feb2018{year{2018}, February};
57 ASSERT_NOEXCEPT ( Feb2018/weekday_indexed{Tuesday, 2});
58 ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb2018/weekday_indexed{Tuesday, 2}));
60 static_assert((Feb2018/weekday_indexed{Tuesday, 2}).year() == year{2018}, "" );
61 static_assert((Feb2018/weekday_indexed{Tuesday, 2}).month() == February, "" );
62 static_assert((Feb2018/weekday_indexed{Tuesday, 2}).weekday() == Tuesday, "" );
64 for (int i = 1000; i < 1010; ++i)
65 for (int j = 1; j <= 12; ++j)
66 for (unsigned k = 0; k <= 6; ++k)
67 for (unsigned l = 1; l <= 5; ++l)
69 year y(i);
70 month m(j);
71 weekday wd{k};
72 year_month_weekday ymd = year_month{y,m}/weekday_indexed{wd,l};
73 assert(ymd.year() == y);
74 assert(ymd.month() == m);
75 assert(ymd.weekday() == wd);
79 { // operator/(const year& y, const month_weekday& mwd) (and switched)
80 constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
81 ASSERT_NOEXCEPT ( year{2018}/Feb1stTues);
82 ASSERT_SAME_TYPE(year_month_weekday, decltype(year{2018}/Feb1stTues));
83 ASSERT_NOEXCEPT ( Feb1stTues/year{2018});
84 ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/year{2018}));
86 static_assert((year{2018}/Feb1stTues).year() == year{2018}, "" );
87 static_assert((year{2018}/Feb1stTues).month() == February, "" );
88 static_assert((year{2018}/Feb1stTues).weekday() == Tuesday, "" );
90 for (int i = 1000; i < 1010; ++i)
91 for (int j = 1; j <= 12; ++j)
92 for (unsigned k = 0; k <= 6; ++k)
93 for (unsigned l = 1; l <= 5; ++l)
95 year y(i);
96 month m(j);
97 weekday wd{k};
98 month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
99 year_month_weekday ymd1 = y/mwd;
100 year_month_weekday ymd2 = mwd/y;
101 assert(ymd1.year() == y);
102 assert(ymd2.year() == y);
103 assert(ymd1.month() == m);
104 assert(ymd2.month() == m);
105 assert(ymd1.weekday() == wd);
106 assert(ymd2.weekday() == wd);
107 assert(ymd1 == ymd2);
112 { // operator/(int y, const month_weekday& mwd) (and switched)
113 constexpr month_weekday Feb1stTues{February, weekday_indexed{Tuesday, 1}};
114 ASSERT_NOEXCEPT ( 2018/Feb1stTues);
115 ASSERT_SAME_TYPE(year_month_weekday, decltype(2018/Feb1stTues));
116 ASSERT_NOEXCEPT ( Feb1stTues/2018);
117 ASSERT_SAME_TYPE(year_month_weekday, decltype(Feb1stTues/2018));
119 static_assert((2018/Feb1stTues).year() == year{2018}, "" );
120 static_assert((2018/Feb1stTues).month() == February, "" );
121 static_assert((2018/Feb1stTues).weekday() == Tuesday, "" );
123 for (int i = 1000; i < 1010; ++i)
124 for (int j = 1; j <= 12; ++j)
125 for (unsigned k = 0; k <= 6; ++k)
126 for (unsigned l = 1; l <= 5; ++l)
128 year y(i);
129 month m(j);
130 weekday wd{k};
131 month_weekday mwd{m, weekday_indexed{weekday{k}, l}};
132 year_month_weekday ymd1 = i/mwd;
133 year_month_weekday ymd2 = mwd/i;
134 assert(ymd1.year() == y);
135 assert(ymd2.year() == y);
136 assert(ymd1.month() == m);
137 assert(ymd2.month() == m);
138 assert(ymd1.weekday() == wd);
139 assert(ymd2.weekday() == wd);
140 assert(ymd1 == ymd2);
144 return 0;