| 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 day; |
| 12 | |
| 13 | // day() = default; |
| 14 | // explicit constexpr day(unsigned d) noexcept; |
| 15 | // explicit constexpr operator unsigned() const noexcept; |
| 16 | |
| 17 | // Effects: Constructs an object of type day by initializing d_ with d. |
| 18 | // The value held is unspecified if d is not in the range [0, 255]. |
| 19 | |
| 20 | #include <chrono> |
| 21 | #include <type_traits> |
| 22 | #include <cassert> |
| 23 | |
| 24 | #include "test_macros.h" |
| 25 | |
| 26 | int main(int, char**) |
| 27 | { |
| 28 | using day = std::chrono::day; |
| 29 | |
| 30 | ASSERT_NOEXCEPT(day{}); |
| 31 | ASSERT_NOEXCEPT(day(0U)); |
| 32 | ASSERT_NOEXCEPT(static_cast<unsigned>(day(0U))); |
| 33 | |
| 34 | constexpr day d0{}; |
| 35 | static_assert(static_cast<unsigned>(d0) == 0, "" ); |
| 36 | |
| 37 | constexpr day d1{1}; |
| 38 | static_assert(static_cast<unsigned>(d1) == 1, "" ); |
| 39 | |
| 40 | for (unsigned i = 0; i <= 255; ++i) |
| 41 | { |
| 42 | day d(i); |
| 43 | assert(static_cast<unsigned>(d) == i); |
| 44 | } |
| 45 | |
| 46 | return 0; |
| 47 | } |
| 48 | |