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