[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.ymd / time.cal.ymd.members / plus_minus_equal_year.pass.cpp
blobe886308f2c6111ecb03676b7ee1597e0d4493b86
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_day;
13 // constexpr year_month_day& operator+=(const years& d) noexcept;
14 // constexpr year_month_day& 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 day = std::chrono::day;
25 using year_month_day = std::chrono::year_month_day;
26 using years = std::chrono::years;
28 constexpr bool test() {
29 for (int i = 1000; i <= 1010; ++i) {
30 month m{2};
31 day d{23};
32 year_month_day ym(year{i}, m, d);
33 assert(static_cast<int>((ym += years{2}).year()) == i + 2);
34 assert(ym.month() == m);
35 assert(ym.day() == d);
36 assert(static_cast<int>((ym).year()) == i + 2);
37 assert(ym.month() == m);
38 assert(ym.day() == d);
39 assert(static_cast<int>((ym -= years{1}).year()) == i + 1);
40 assert(ym.month() == m);
41 assert(ym.day() == d);
42 assert(static_cast<int>((ym).year()) == i + 1);
43 assert(ym.month() == m);
44 assert(ym.day() == d);
47 return true;
50 int main(int, char**) {
51 ASSERT_NOEXCEPT(std::declval<year_month_day&>() += std::declval<years>());
52 ASSERT_NOEXCEPT(std::declval<year_month_day&>() -= std::declval<years>());
54 ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() += std::declval<years>()));
55 ASSERT_SAME_TYPE(year_month_day&, decltype(std::declval<year_month_day&>() -= std::declval<years>()));
57 test();
58 static_assert(test());
60 return 0;