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 year& operator++() noexcept;
15 //  constexpr year operator++(int) noexcept;
16 
17 
18 #include <chrono>
19 #include <type_traits>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 template <typename Y>
testConstexpr()25 constexpr bool testConstexpr()
26 {
27     Y y1{10};
28     if (static_cast<int>(++y1) != 11) return false;
29     if (static_cast<int>(y1++) != 11) return false;
30     if (static_cast<int>(y1)   != 12) return false;
31     return true;
32 }
33 
main()34 int main()
35 {
36     using year = std::chrono::year;
37     ASSERT_NOEXCEPT(++(std::declval<year&>())  );
38     ASSERT_NOEXCEPT(  (std::declval<year&>())++);
39 
40     ASSERT_SAME_TYPE(year , decltype(  std::declval<year&>()++));
41     ASSERT_SAME_TYPE(year&, decltype(++std::declval<year&>()  ));
42 
43     static_assert(testConstexpr<year>(), "");
44 
45     for (int i = 11000; i <= 11020; ++i)
46     {
47         year year(i);
48         assert(static_cast<int>(++year) == i + 1);
49         assert(static_cast<int>(year++) == i + 1);
50         assert(static_cast<int>(year)   == i + 2);
51     }
52 }
53