[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.month / time.cal.month.members / plus_minus_equal.pass.cpp
blobd825ef7d6cefa3bd6bbfc18a1ccca61d5f5367df
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;
13 // constexpr month& operator+=(const month& d) noexcept;
14 // constexpr month& operator-=(const month& d) noexcept;
16 #include <chrono>
17 #include <type_traits>
18 #include <cassert>
20 #include "test_macros.h"
22 constexpr bool test() {
23 using month = std::chrono::month;
24 using months = std::chrono::months;
26 for (unsigned i = 1; i <= 10; ++i) {
27 month m(i);
28 int exp = i + 10;
29 while (exp > 12)
30 exp -= 12;
31 assert(static_cast<unsigned>(m += months{10}) == static_cast<unsigned>(exp));
32 assert(static_cast<unsigned>(m) == static_cast<unsigned>(exp));
33 assert(m.ok());
36 for (unsigned i = 1; i <= 10; ++i) {
37 month m(i);
38 int exp = i - 9;
39 while (exp < 1)
40 exp += 12;
41 assert(static_cast<unsigned>(m -= months{9}) == static_cast<unsigned>(exp));
42 assert(static_cast<unsigned>(m) == static_cast<unsigned>(exp));
43 assert(m.ok());
45 return true;
48 int main(int, char**) {
49 using month = std::chrono::month;
50 using months = std::chrono::months;
52 ASSERT_NOEXCEPT(std::declval<month&>() += std::declval<months&>());
53 ASSERT_NOEXCEPT(std::declval<month&>() -= std::declval<months&>());
54 ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() += std::declval<months&>()));
55 ASSERT_SAME_TYPE(month&, decltype(std::declval<month&>() -= std::declval<months&>()));
57 test();
58 static_assert(test());
60 return 0;