1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
10 
11 // <chrono>
12 // class year;
13 
14 // constexpr bool ok() const noexcept;
15 //  Returns: min() <= y_ && y_ <= max().
16 //
17 //  static constexpr year min() noexcept;
18 //   Returns year{ 32767};
19 //  static constexpr year max() noexcept;
20 //   Returns year{-32767};
21 
22 #include <chrono>
23 #include <type_traits>
24 #include <cassert>
25 
26 #include "test_macros.h"
27 
main()28 int main()
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