[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.operators / month_weekday_last.pass.cpp
blob5f5e1e7398931258a07431156a1861318c1a64cf
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 month_weekday_last;
13 // constexpr month_weekday_last
14 // operator/(const month& m, const weekday_last& wdl) noexcept;
15 // Returns: {m, wdl}.
17 // constexpr month_weekday_last
18 // operator/(int m, const weekday_last& wdl) noexcept;
19 // Returns: month(m) / wdl.
21 // constexpr month_weekday_last
22 // operator/(const weekday_last& wdl, const month& m) noexcept;
23 // Returns: m / wdl.
25 // constexpr month_weekday_last
26 // operator/(const weekday_last& wdl, int m) noexcept;
27 // Returns: month(m) / wdl.
29 #include <chrono>
30 #include <type_traits>
31 #include <cassert>
33 #include "test_macros.h"
35 int main(int, char**)
37 using month_weekday = std::chrono::month_weekday;
38 using month = std::chrono::month;
39 using weekday = std::chrono::weekday;
40 using weekday_last = std::chrono::weekday_last;
41 using month_weekday_last = std::chrono::month_weekday_last;
43 constexpr weekday Tuesday = std::chrono::Tuesday;
44 constexpr month February = std::chrono::February;
45 constexpr std::chrono::last_spec last = std::chrono::last;
47 { // operator/(const month& m, const weekday_last& wdi) (and switched)
48 ASSERT_NOEXCEPT (February/Tuesday[last]);
49 ASSERT_SAME_TYPE(month_weekday_last, decltype(February/Tuesday[last]));
50 ASSERT_NOEXCEPT (Tuesday[last]/February);
51 ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/February));
53 // Run the example
55 constexpr month_weekday_last wdi = February/Tuesday[last];
56 static_assert(wdi.month() == February, "");
57 static_assert(wdi.weekday_last() == Tuesday[last], "");
60 for (int i = 1; i <= 12; ++i)
61 for (unsigned j = 0; j <= 6; ++j)
63 month m(i);
64 weekday_last wdi = weekday{j}[last];
65 month_weekday_last mwd1 = m/wdi;
66 month_weekday_last mwd2 = wdi/m;
67 assert(mwd1.month() == m);
68 assert(mwd1.weekday_last() == wdi);
69 assert(mwd2.month() == m);
70 assert(mwd2.weekday_last() == wdi);
71 assert(mwd1 == mwd2);
76 { // operator/(int m, const weekday_last& wdi) (and switched)
77 ASSERT_NOEXCEPT (2/Tuesday[2]);
78 ASSERT_SAME_TYPE(month_weekday_last, decltype(2/Tuesday[last]));
79 ASSERT_NOEXCEPT (Tuesday[2]/2);
80 ASSERT_SAME_TYPE(month_weekday_last, decltype(Tuesday[last]/2));
82 // Run the example
84 constexpr month_weekday wdi = 2/Tuesday[3];
85 static_assert(wdi.month() == February, "");
86 static_assert(wdi.weekday_indexed() == Tuesday[3], "");
89 for (int i = 1; i <= 12; ++i)
90 for (unsigned j = 0; j <= 6; ++j)
92 weekday_last wdi = weekday{j}[last];
93 month_weekday_last mwd1 = i/wdi;
94 month_weekday_last mwd2 = wdi/i;
95 assert(mwd1.month() == month(i));
96 assert(mwd1.weekday_last() == wdi);
97 assert(mwd2.month() == month(i));
98 assert(mwd2.weekday_last() == wdi);
99 assert(mwd1 == mwd2);
103 return 0;