1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // constexpr year_month operator/(const year& y, const month& m) noexcept;
16 // constexpr year_month operator/(const year& y, int m) noexcept;
17 // Returns: y / month(m).
20 #include <type_traits>
23 #include "test_macros.h"
27 using month
= std::chrono::month
;
28 using year
= std::chrono::year
;
29 using year_month
= std::chrono::year_month
;
31 constexpr month February
= std::chrono::February
;
33 { // operator/(const year& y, const month& m)
34 ASSERT_NOEXCEPT ( year
{2018}/February
);
35 ASSERT_SAME_TYPE(year_month
, decltype(year
{2018}/February
));
37 static_assert((year
{2018}/February
).year() == year
{2018}, "");
38 static_assert((year
{2018}/February
).month() == month
{2}, "");
39 for (int i
= 1000; i
<= 1030; ++i
)
40 for (unsigned j
= 1; j
<= 12; ++j
)
42 year_month ym
= year
{i
}/month
{j
};
43 assert(static_cast<int>(ym
.year()) == i
);
44 assert(static_cast<unsigned>(ym
.month()) == j
);
49 { // operator/(const year& y, const int m)
50 ASSERT_NOEXCEPT ( year
{2018}/4);
51 ASSERT_SAME_TYPE(year_month
, decltype(year
{2018}/4));
53 static_assert((year
{2018}/2).year() == year
{2018}, "");
54 static_assert((year
{2018}/2).month() == month
{2}, "");
56 for (int i
= 1000; i
<= 1030; ++i
)
57 for (unsigned j
= 1; j
<= 12; ++j
)
59 year_month ym
= year
{i
}/j
;
60 assert(static_cast<int>(ym
.year()) == i
);
61 assert(static_cast<unsigned>(ym
.month()) == j
);