| 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 |
| 9 | |
| 10 | // <chrono> |
| 11 | // class year_month; |
| 12 | |
| 13 | // year_month() = default; |
| 14 | // constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept; |
| 15 | // |
| 16 | // Effects: Constructs an object of type year_month by initializing y_ with y, and m_ with m. |
| 17 | // |
| 18 | // constexpr chrono::year year() const noexcept; |
| 19 | // constexpr chrono::month month() const noexcept; |
| 20 | // constexpr bool ok() const noexcept; |
| 21 | |
| 22 | #include <chrono> |
| 23 | #include <type_traits> |
| 24 | #include <cassert> |
| 25 | |
| 26 | #include "test_macros.h" |
| 27 | |
| 28 | int main(int, char**) |
| 29 | { |
| 30 | using year = std::chrono::year; |
| 31 | using month = std::chrono::month; |
| 32 | using year_month = std::chrono::year_month; |
| 33 | |
| 34 | ASSERT_NOEXCEPT(year_month{}); |
| 35 | ASSERT_NOEXCEPT(year_month{year{1}, month{1}}); |
| 36 | |
| 37 | constexpr year_month ym0{}; |
| 38 | static_assert( ym0.year() == year{}, "" ); |
| 39 | static_assert( ym0.month() == month{}, "" ); |
| 40 | static_assert(!ym0.ok(), "" ); |
| 41 | |
| 42 | constexpr year_month ym1{year{2018}, std::chrono::January}; |
| 43 | static_assert( ym1.year() == year{2018}, "" ); |
| 44 | static_assert( ym1.month() == std::chrono::January, "" ); |
| 45 | static_assert( ym1.ok(), "" ); |
| 46 | |
| 47 | constexpr year_month ym2{year{2018}, month{}}; |
| 48 | static_assert( ym2.year() == year{2018}, "" ); |
| 49 | static_assert( ym2.month() == month{}, "" ); |
| 50 | static_assert(!ym2.ok(), "" ); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |