]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/std/time/month/1.cc
1 // { dg-options "-std=gnu++2a" }
2 // { dg-do compile { target c++2a } }
4 // Copyright (C) 2020-2023 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // Class template day [time.cal.month]
28 using namespace std::chrono
;
38 static_assert(February
+ months
{11} == January
);
39 static_assert(January
+ months
{1200} == January
);
40 static_assert(January
+ months
{1201} == February
);
41 static_assert(months
{-1200} + January
== January
);
42 static_assert(months
{-1201} + January
== December
);
43 static_assert(January
- months
{1200} == January
);
44 static_assert(January
- months
{-1200} == January
);
45 static_assert(January
- months
{1201} == December
);
47 static_assert(January
- February
== months
{11});
48 static_assert(February
- January
== months
{1});
49 static_assert(June
- June
== months
{});
51 static_assert(++month
{4} == month
{5});
52 static_assert(month
{4}++ == month
{4});
53 static_assert(--month
{4} == month
{3});
54 static_assert(month
{4}-- == month
{4});
55 static_assert((month
{4} += months
{3}) == month
{7});
56 static_assert((month
{4} -= months
{3}) == month
{1});
58 static_assert(!month
{}.ok());
59 static_assert(month
{1}.ok());
60 static_assert(month
{12}.ok());
61 static_assert(!month
{13}.ok());
63 static_assert(unsigned{month
{7}} == 7);
65 static_assert(!(month
{0} == month
{1}));
66 static_assert( (month
{0} != month
{2}));
67 static_assert( (month
{0} < month
{3}));
68 static_assert(!(month
{0} > month
{4}));
69 static_assert( (month
{0} <= month
{5}));
70 static_assert(!(month
{0} >= month
{6}));
72 static_assert(month
{0} <=> month
{1} == std::strong_ordering::less
);
73 static_assert(month
{3} <=> month
{3} == std::strong_ordering::equal
);
74 static_assert(month
{5} <=> month
{2} == std::strong_ordering::greater
);