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