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// year() = default;
14// explicit constexpr year(int m) noexcept;
15// explicit constexpr operator int() const noexcept;
16
17// Effects: Constructs an object of type year by initializing y_ with y.
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
26int main(int, char**)
27{
28 using year = std::chrono::year;
29
30 ASSERT_NOEXCEPT(year{});
31 ASSERT_NOEXCEPT(year(0U));
32 ASSERT_NOEXCEPT(static_cast<int>(year(0U)));
33
34 constexpr year y0{};
35 static_assert(static_cast<int>(y0) == 0, "");
36
37 constexpr year y1{1};
38 static_assert(static_cast<int>(y1) == 1, "");
39
40 for (int i = 0; i <= 2550; i += 7)
41 {
42 year yr(i);
43 assert(static_cast<int>(yr) == i);
44 }
45
46 return 0;
47}
48

source code of libcxx/test/std/time/time.cal/time.cal.year/time.cal.year.members/ctor.pass.cpp