[PhaseOrdering][X86] Add better SSE/AVX test coverage for add-sub tests
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.ymdlast / time.cal.ymdlast.members / plus_minus_equal_month.pass.cpp
blobc860a73c73a6f332e19095d6cba271b9e8c492c2
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_last;
13 // constexpr year_month_day_last& operator+=(const months& m) noexcept;
14 // constexpr year_month_day_last& operator-=(const months& m) noexcept;
16 #include <chrono>
17 #include <cassert>
18 #include <type_traits>
19 #include <utility>
21 #include "test_macros.h"
23 using year = std::chrono::year;
24 using month = std::chrono::month;
25 using month_day_last = std::chrono::month_day_last;
26 using year_month_day_last = std::chrono::year_month_day_last;
27 using months = std::chrono::months;
29 constexpr bool test() {
30 for (unsigned i = 0; i <= 10; ++i) {
31 year y{1234};
32 month_day_last mdl{month{i}};
33 year_month_day_last ymdl(y, mdl);
34 assert(static_cast<unsigned>((ymdl += months{2}).month()) == i + 2);
35 assert(ymdl.year() == y);
36 assert(static_cast<unsigned>((ymdl).month()) == i + 2);
37 assert(ymdl.year() == y);
38 assert(static_cast<unsigned>((ymdl -= months{1}).month()) == i + 1);
39 assert(ymdl.year() == y);
40 assert(static_cast<unsigned>((ymdl).month()) == i + 1);
41 assert(ymdl.year() == y);
44 { // Test year wrapping
45 year_month_day_last ymdl{year{2020}, month_day_last{month{4}}};
47 ymdl += months{12};
48 assert((ymdl == year_month_day_last{year{2021}, month_day_last{month{4}}}));
50 ymdl -= months{12};
51 assert((ymdl == year_month_day_last{year{2020}, month_day_last{month{4}}}));
54 return true;
57 int main(int, char**) {
58 ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() += std::declval<months>());
59 ASSERT_NOEXCEPT(std::declval<year_month_day_last&>() -= std::declval<months>());
61 ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() += std::declval<months>()));
62 ASSERT_SAME_TYPE(year_month_day_last&, decltype(std::declval<year_month_day_last&>() -= std::declval<months>()));
64 test();
65 static_assert(test());
67 return 0;