[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.operators / month_day.pass.cpp
blob1def28f7a0144782875197281fc46171dc2dfabf
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_day;
13 // constexpr month_day
14 // operator/(const month& m, const day& d) noexcept;
15 // Returns: {m, d}.
17 // constexpr month_day
18 // operator/(const day& d, const month& m) noexcept;
19 // Returns: m / d.
21 // constexpr month_day
22 // operator/(const month& m, int d) noexcept;
23 // Returns: m / day(d).
25 // constexpr month_day
26 // operator/(int m, const day& d) noexcept;
27 // Returns: month(m) / d.
29 // constexpr month_day
30 // operator/(const day& d, int m) noexcept;
31 // Returns: month(m) / d.
33 #include <chrono>
34 #include <type_traits>
35 #include <cassert>
37 #include "test_macros.h"
39 int main(int, char**)
41 using month_day = std::chrono::month_day;
42 using month = std::chrono::month;
43 using day = std::chrono::day;
45 constexpr month February = std::chrono::February;
47 { // operator/(const month& m, const day& d) (and switched)
48 ASSERT_NOEXCEPT ( February/day{1});
49 ASSERT_SAME_TYPE(month_day, decltype(February/day{1}));
50 ASSERT_NOEXCEPT ( day{1}/February);
51 ASSERT_SAME_TYPE(month_day, decltype(day{1}/February));
53 for (int i = 1; i <= 12; ++i)
54 for (unsigned j = 0; j <= 30; ++j)
56 month m(i);
57 day d{j};
58 month_day md1 = m/d;
59 month_day md2 = d/m;
60 assert(md1.month() == m);
61 assert(md1.day() == d);
62 assert(md2.month() == m);
63 assert(md2.day() == d);
64 assert(md1 == md2);
69 { // operator/(const month& m, int d) (NOT switched)
70 ASSERT_NOEXCEPT ( February/2);
71 ASSERT_SAME_TYPE(month_day, decltype(February/2));
73 for (int i = 1; i <= 12; ++i)
74 for (unsigned j = 0; j <= 30; ++j)
76 month m(i);
77 day d(j);
78 month_day md1 = m/j;
79 assert(md1.month() == m);
80 assert(md1.day() == d);
85 { // operator/(const day& d, int m) (and switched)
86 ASSERT_NOEXCEPT ( day{2}/2);
87 ASSERT_SAME_TYPE(month_day, decltype(day{2}/2));
88 ASSERT_NOEXCEPT ( 2/day{2});
89 ASSERT_SAME_TYPE(month_day, decltype(2/day{2}));
91 for (int i = 1; i <= 12; ++i)
92 for (unsigned j = 0; j <= 30; ++j)
94 month m(i);
95 day d(j);
96 month_day md1 = d/i;
97 month_day md2 = i/d;
98 assert(md1.month() == m);
99 assert(md1.day() == d);
100 assert(md2.month() == m);
101 assert(md2.day() == d);
102 assert(md1 == md2);
106 return 0;