]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/std/time/year/1.cc
1 // { dg-do compile { target c++20 } }
3 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 // Class template day [time.cal.year]
27 using namespace std::chrono
;
37 static_assert(++year
{4} == year
{5});
38 static_assert(year
{4}++ == year
{4});
39 static_assert(--year
{4} == year
{3});
40 static_assert(year
{4}-- == year
{4});
41 static_assert((year
{4} += years
{3}) == year
{7});
42 static_assert((year
{4} -= years
{3}) == year
{1});
44 static_assert(year
{3} + years
{7} == year
{10});
45 static_assert(years
{3} + year
{7} == year
{10});
46 static_assert(year
{3} - years
{7} == year
{-4});
47 static_assert(year
{10} - year
{30} == years
{-20});
52 static_assert((-year
{1066} == year
{-1066}));
53 static_assert((-year
{-332} == year
{332}));
54 static_assert((+year
{1066} == year
{1066}));
55 static_assert((+year
{-332} == year
{-332}));
60 static_assert(year
{-12345}.ok());
61 static_assert(year
{1}.ok());
62 static_assert(year
{12}.ok());
63 static_assert(year
{13}.ok());
65 static_assert(int{year
{-42}} == -42);
67 static_assert(!(year
{0} == year
{1}));
68 static_assert( (year
{0} != year
{2}));
69 static_assert( (year
{0} < year
{3}));
70 static_assert(!(year
{0} > year
{4}));
71 static_assert( (year
{0} <= year
{5}));
72 static_assert(!(year
{0} >= year
{6}));
74 static_assert(year
{10} <=> year
{11} == std::strong_ordering::less
);
75 static_assert(year
{13} <=> year
{13} == std::strong_ordering::equal
);
76 static_assert(year
{15} <=> year
{12} == std::strong_ordering::greater
);
78 static_assert( year
{400}.is_leap());
79 static_assert( year
{1984}.is_leap());
80 static_assert(!year
{1}.is_leap());
81 static_assert( year
{1600}.is_leap());
82 static_assert(!year
{3000}.is_leap());
83 static_assert(!year
{2019}.is_leap());