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
11 // class year_month_weekday;
13 // constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept;
14 // Returns: x.year() == y.year() && x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed()
19 #include <type_traits>
22 #include "test_macros.h"
23 #include "test_comparisons.h"
27 using year
= std::chrono::year
;
28 using month
= std::chrono::month
;
29 using weekday_indexed
= std::chrono::weekday_indexed
;
30 using weekday
= std::chrono::weekday
;
31 using year_month_weekday
= std::chrono::year_month_weekday
;
33 AssertEqualityAreNoexcept
<year_month_weekday
>();
34 AssertEqualityReturnBool
<year_month_weekday
>();
36 constexpr month January
= std::chrono::January
;
37 constexpr month February
= std::chrono::February
;
38 constexpr weekday Tuesday
= std::chrono::Tuesday
;
40 static_assert( testEquality(
41 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
42 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
46 static_assert( testEquality(
47 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
48 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 2}},
52 static_assert( testEquality(
53 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
54 year_month_weekday
{year
{1234}, February
, weekday_indexed
{Tuesday
, 1}},
58 static_assert( testEquality(
59 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
60 year_month_weekday
{year
{1235}, January
, weekday_indexed
{Tuesday
, 1}},
64 // different month and day
65 static_assert( testEquality(
66 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 1}},
67 year_month_weekday
{year
{1234}, February
, weekday_indexed
{Tuesday
, 2}},
70 // different year and month
71 static_assert( testEquality(
72 year_month_weekday
{year
{1234}, February
, weekday_indexed
{Tuesday
, 1}},
73 year_month_weekday
{year
{1235}, January
, weekday_indexed
{Tuesday
, 1}},
76 // different year and day
77 static_assert( testEquality(
78 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, 2}},
79 year_month_weekday
{year
{1235}, January
, weekday_indexed
{Tuesday
, 1}},
82 // different year, month and day
83 static_assert( testEquality(
84 year_month_weekday
{year
{1234}, February
, weekday_indexed
{Tuesday
, 2}},
85 year_month_weekday
{year
{1235}, January
, weekday_indexed
{Tuesday
, 1}},
89 // same year, different days
90 for (unsigned i
= 1; i
< 28; ++i
)
91 for (unsigned j
= 1; j
< 28; ++j
)
93 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, i
}},
94 year_month_weekday
{year
{1234}, January
, weekday_indexed
{Tuesday
, j
}},
97 // same year, different months
98 for (unsigned i
= 1; i
< 12; ++i
)
99 for (unsigned j
= 1; j
< 12; ++j
)
100 assert((testEquality(
101 year_month_weekday
{year
{1234}, month
{i
}, weekday_indexed
{Tuesday
, 1}},
102 year_month_weekday
{year
{1234}, month
{j
}, weekday_indexed
{Tuesday
, 1}},
105 // same month, different years
106 for (int i
= 1000; i
< 2000; ++i
)
107 for (int j
= 1000; j
< 2000; ++j
)
108 assert((testEquality(
109 year_month_weekday
{year
{i
}, January
, weekday_indexed
{Tuesday
, 1}},
110 year_month_weekday
{year
{j
}, January
, weekday_indexed
{Tuesday
, 1}},