[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.ymwdlast / time.cal.ymwdlast.members / plus_minus_equal_year.pass.cpp
blobdb8c9f482a16d2bcf0d49e683bc8d17f33a5a3bf
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_last;
13 // constexpr year_month_weekday_last& operator+=(const years& d) noexcept;
14 // constexpr year_month_weekday_last& operator-=(const years& d) noexcept;
16 #include <chrono>
17 #include <type_traits>
18 #include <cassert>
20 #include "test_macros.h"
22 using year = std::chrono::year;
23 using month = std::chrono::month;
24 using weekday = std::chrono::weekday;
25 using weekday_last = std::chrono::weekday_last;
26 using year_month_weekday_last = std::chrono::year_month_weekday_last;
27 using years = std::chrono::years;
29 constexpr bool test() {
30 constexpr weekday Tuesday = std::chrono::Tuesday;
31 constexpr month January = std::chrono::January;
33 for (int i = 1000; i <= 1010; ++i) {
34 year_month_weekday_last ymwd(year{i}, January, weekday_last{Tuesday});
36 assert(static_cast<int>((ymwd += years{2}).year()) == i + 2);
37 assert(ymwd.month() == January);
38 assert(ymwd.weekday() == Tuesday);
40 assert(static_cast<int>((ymwd).year()) == i + 2);
41 assert(ymwd.month() == January);
42 assert(ymwd.weekday() == Tuesday);
44 assert(static_cast<int>((ymwd -= years{1}).year()) == i + 1);
45 assert(ymwd.month() == January);
46 assert(ymwd.weekday() == Tuesday);
48 assert(static_cast<int>((ymwd).year()) == i + 1);
49 assert(ymwd.month() == January);
50 assert(ymwd.weekday() == Tuesday);
53 return true;
56 int main(int, char**) {
57 ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() += std::declval<years>());
58 ASSERT_NOEXCEPT(std::declval<year_month_weekday_last&>() -= std::declval<years>());
60 ASSERT_SAME_TYPE(
61 year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() += std::declval<years>()));
62 ASSERT_SAME_TYPE(
63 year_month_weekday_last&, decltype(std::declval<year_month_weekday_last&>() -= std::declval<years>()));
65 test();
66 static_assert(test());
68 return 0;