Debian Codegraph @

libstdc++-v3/testsuite/std/time/month_day_last/1.cc

raw
1 // { dg-do compile { target c++20 } }
2
3 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
10
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.
15
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/>.
19
20 // Class template day [time.cal.month_day_last]
21
22 #include <chrono>
23
24 constexpr void
25 constexpr_month_day_last()
26 {
27 using namespace std::chrono;
28 using mdl = month_day_last;
29
30 constexpr auto mdl0 = February / last;
31 static_assert(mdl0.month() == February);
32
33 constexpr auto mdl1 = month_day_last{month{3}};
34 static_assert(mdl1.month() == month{3});
35
36 static_assert( mdl{month{3}}.ok());
37 static_assert(!mdl{month{0}}.ok());
38 static_assert(!mdl{month{13}}.ok());
39
40 static_assert( (mdl{month{1}} == mdl{month{1}}));
41 static_assert(!(mdl{month{2}} != mdl{month{2}}));
42 static_assert(!(mdl{month{3}} < mdl{month{3}}));
43 static_assert(!(mdl{month{4}} > mdl{month{4}}));
44 static_assert( (mdl{month{5}} <= mdl{month{5}}));
45 static_assert( (mdl{month{6}} >= mdl{month{6}}));
46 static_assert( (mdl{month{10}} == mdl{month{10}}));
47 static_assert( (mdl{month{9}} != mdl{month{10}}));
48 static_assert( (mdl{month{8}} < mdl{month{10}}));
49 static_assert( (mdl{month{11}} > mdl{month{10}}));
50 static_assert( (mdl{month{10}} <= mdl{month{10}}));
51 static_assert( (mdl{month{10}} >= mdl{month{10}}));
52
53 static_assert( (mdl{month{1}} <=> mdl{month{1}})
54 == std::strong_ordering::equal);
55 static_assert( (mdl{month{11}} <=> mdl{month{10}})
56 == std::strong_ordering::greater);
57 static_assert( (mdl{month{8}} <=> mdl{month{10}})
58 == std::strong_ordering::less);
59
60 static_assert(August/last == mdl{month{8}});
61 static_assert(8/last == mdl{month{8}});
62 static_assert(last/August == mdl{month{8}});
63 static_assert(last/8 == mdl{month{8}});
64 }