[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.pass.cpp
blob31888b3c21241bcd76cd9d438631f4378dbdf4f5
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;
13 // constexpr month_weekday
14 // operator/(const month& m, const weekday_indexed& wdi) noexcept;
15 // Returns: {m, wdi}.
17 // constexpr month_weekday
18 // operator/(int m, const weekday_indexed& wdi) noexcept;
19 // Returns: month(m) / wdi.
21 // constexpr month_weekday
22 // operator/(const weekday_indexed& wdi, const month& m) noexcept;
23 // Returns: m / wdi. constexpr month_weekday
25 // constexpr month_weekday
26 // operator/(const weekday_indexed& wdi, int m) noexcept;
27 // Returns: month(m) / wdi.
30 // [Example:
31 // constexpr auto mwd = February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
32 // static_assert(mwd.month() == February);
33 // static_assert(mwd.weekday_indexed() == Tuesday[3]);
34 // -end example]
36 #include <chrono>
37 #include <type_traits>
38 #include <cassert>
40 #include "test_macros.h"
42 int main(int, char**)
44 using month_weekday = std::chrono::month_weekday;
45 using month = std::chrono::month;
46 using weekday = std::chrono::weekday;
47 using weekday_indexed = std::chrono::weekday_indexed;
49 constexpr weekday Tuesday = std::chrono::Tuesday;
50 constexpr month February = std::chrono::February;
52 { // operator/(const month& m, const weekday_indexed& wdi) (and switched)
53 ASSERT_NOEXCEPT (February/Tuesday[2]);
54 ASSERT_SAME_TYPE(month_weekday, decltype(February/Tuesday[2]));
55 ASSERT_NOEXCEPT (Tuesday[2]/February);
56 ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/February));
58 // Run the example
60 constexpr month_weekday wdi = February/Tuesday[3];
61 static_assert(wdi.month() == February, "");
62 static_assert(wdi.weekday_indexed() == Tuesday[3], "");
65 for (int i = 1; i <= 12; ++i)
66 for (unsigned j = 0; j <= 6; ++j)
67 for (unsigned k = 1; k <= 5; ++k)
69 month m(i);
70 weekday_indexed wdi = weekday{j}[k];
71 month_weekday mwd1 = m/wdi;
72 month_weekday mwd2 = wdi/m;
73 assert(mwd1.month() == m);
74 assert(mwd1.weekday_indexed() == wdi);
75 assert(mwd2.month() == m);
76 assert(mwd2.weekday_indexed() == wdi);
77 assert(mwd1 == mwd2);
82 { // operator/(int m, const weekday_indexed& wdi) (and switched)
83 ASSERT_NOEXCEPT (2/Tuesday[2]);
84 ASSERT_SAME_TYPE(month_weekday, decltype(2/Tuesday[2]));
85 ASSERT_NOEXCEPT (Tuesday[2]/2);
86 ASSERT_SAME_TYPE(month_weekday, decltype(Tuesday[2]/2));
88 // Run the example
90 constexpr month_weekday wdi = 2/Tuesday[3];
91 static_assert(wdi.month() == February, "");
92 static_assert(wdi.weekday_indexed() == Tuesday[3], "");
95 for (int i = 1; i <= 12; ++i)
96 for (unsigned j = 0; j <= 6; ++j)
97 for (unsigned k = 1; k <= 5; ++k)
99 weekday_indexed wdi = weekday{j}[k];
100 month_weekday mwd1 = i/wdi;
101 month_weekday mwd2 = wdi/i;
102 assert(mwd1.month() == month(i));
103 assert(mwd1.weekday_indexed() == wdi);
104 assert(mwd2.month() == month(i));
105 assert(mwd2.weekday_indexed() == wdi);
106 assert(mwd1 == mwd2);
110 return 0;