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 is_leap() const noexcept;
14 //  y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)
15 //
16 
17 #include <chrono>
18 #include <type_traits>
19 #include <cassert>
20 
21 #include "test_macros.h"
22 
main(int,char **)23 int main(int, char**)
24 {
25     using year = std::chrono::year;
26 
27     ASSERT_NOEXCEPT(                year(1).is_leap());
28     ASSERT_SAME_TYPE(bool, decltype(year(1).is_leap()));
29 
30     static_assert(!year{1}.is_leap(), "");
31     static_assert(!year{2}.is_leap(), "");
32     static_assert(!year{3}.is_leap(), "");
33     static_assert( year{4}.is_leap(), "");
34 
35     assert( year{-2000}.is_leap());
36     assert( year{ -400}.is_leap());
37     assert(!year{ -300}.is_leap());
38     assert(!year{ -200}.is_leap());
39 
40     assert(!year{  200}.is_leap());
41     assert(!year{  300}.is_leap());
42     assert( year{  400}.is_leap());
43     assert(!year{ 1997}.is_leap());
44     assert(!year{ 1998}.is_leap());
45     assert(!year{ 1999}.is_leap());
46     assert( year{ 2000}.is_leap());
47     assert(!year{ 2001}.is_leap());
48     assert(!year{ 2002}.is_leap());
49     assert(!year{ 2003}.is_leap());
50     assert( year{ 2004}.is_leap());
51     assert(!year{ 2100}.is_leap());
52 
53   return 0;
54 }
55