| 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; |
| 12 | |
| 13 | // constexpr bool ok() const noexcept; |
| 14 | // Returns: min() <= y_ && y_ <= max(). |
| 15 | // |
| 16 | // static constexpr year min() noexcept; |
| 17 | // Returns year{ 32767}; |
| 18 | // static constexpr year max() noexcept; |
| 19 | // Returns year{-32767}; |
| 20 | |
| 21 | #include <chrono> |
| 22 | #include <cassert> |
| 23 | #include <type_traits> |
| 24 | #include <utility> |
| 25 | |
| 26 | #include "test_macros.h" |
| 27 | |
| 28 | int main(int, char**) |
| 29 | { |
| 30 | using year = std::chrono::year; |
| 31 | |
| 32 | ASSERT_NOEXCEPT( std::declval<const year>().ok()); |
| 33 | ASSERT_SAME_TYPE(bool, decltype(std::declval<const year>().ok())); |
| 34 | |
| 35 | ASSERT_NOEXCEPT( year::max()); |
| 36 | ASSERT_SAME_TYPE(year, decltype(year::max())); |
| 37 | |
| 38 | ASSERT_NOEXCEPT( year::min()); |
| 39 | ASSERT_SAME_TYPE(year, decltype(year::min())); |
| 40 | |
| 41 | static_assert(static_cast<int>(year::min()) == -32767, "" ); |
| 42 | static_assert(static_cast<int>(year::max()) == 32767, "" ); |
| 43 | |
| 44 | assert(year{-20001}.ok()); |
| 45 | assert(year{ -2000}.ok()); |
| 46 | assert(year{ -1}.ok()); |
| 47 | assert(year{ 0}.ok()); |
| 48 | assert(year{ 1}.ok()); |
| 49 | assert(year{ 2000}.ok()); |
| 50 | assert(year{ 20001}.ok()); |
| 51 | |
| 52 | static_assert(!year{-32768}.ok(), "" ); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |