1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 // constexpr bool is_leap() const noexcept;
14 // y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)
18 #include <type_traits>
21 #include "test_macros.h"
25 using year
= std::chrono::year
;
27 ASSERT_NOEXCEPT( year(1).is_leap());
28 ASSERT_SAME_TYPE(bool, decltype(year(1).is_leap()));
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(), "");
35 assert( year
{-2000}.is_leap());
36 assert( year
{ -400}.is_leap());
37 assert(!year
{ -300}.is_leap());
38 assert(!year
{ -200}.is_leap());
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());