[C++20][modules] Fix std::initializer_list recognition if it's exported out of a...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.operators / year_month.pass.cpp
blob2691d32967c6e3fecf77f2d5660f68f4bfcfbd29
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;
13 // constexpr year_month operator/(const year& y, const month& m) noexcept;
14 // Returns: {y, m}.
16 // constexpr year_month operator/(const year& y, int m) noexcept;
17 // Returns: y / month(m).
19 #include <chrono>
20 #include <type_traits>
21 #include <cassert>
23 #include "test_macros.h"
25 int main(int, char**)
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);
65 return 0;