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_month_weekday_last;
13
14 // constexpr bool operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) noexcept;
15 // Returns: x.year() == y.year() && x.month() == y.month() && x.weekday_last() == y.weekday_last()
16 //
17
18
19 #include <chrono>
20 #include <type_traits>
21 #include <cassert>
22
23 #include "test_macros.h"
24 #include "test_comparisons.h"
25
main()26 int main()
27 {
28 using year = std::chrono::year;
29 using month = std::chrono::month;
30 using weekday = std::chrono::weekday;
31 using weekday_last = std::chrono::weekday_last;
32 using year_month_weekday_last = std::chrono::year_month_weekday_last;
33
34 AssertComparisons2AreNoexcept<year_month_weekday_last>();
35 AssertComparisons2ReturnBool<year_month_weekday_last>();
36
37 constexpr month January = std::chrono::January;
38 constexpr month February = std::chrono::February;
39 constexpr weekday Tuesday = std::chrono::Tuesday;
40 constexpr weekday Wednesday = std::chrono::Wednesday;
41
42 static_assert( testComparisons2(
43 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
44 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
45 true), "");
46
47 // different day
48 static_assert( testComparisons2(
49 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
50 year_month_weekday_last{year{1234}, January, weekday_last{Wednesday}},
51 false), "");
52
53 // different month
54 static_assert( testComparisons2(
55 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
56 year_month_weekday_last{year{1234}, February, weekday_last{Tuesday}},
57 false), "");
58
59 // different year
60 static_assert( testComparisons2(
61 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
62 year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
63 false), "");
64
65
66 // different month and day
67 static_assert( testComparisons2(
68 year_month_weekday_last{year{1234}, January, weekday_last{Tuesday}},
69 year_month_weekday_last{year{1234}, February, weekday_last{Wednesday}},
70 false), "");
71
72 // different year and month
73 static_assert( testComparisons2(
74 year_month_weekday_last{year{1234}, February, weekday_last{Tuesday}},
75 year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
76 false), "");
77
78 // different year and day
79 static_assert( testComparisons2(
80 year_month_weekday_last{year{1234}, January, weekday_last{Wednesday}},
81 year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
82 false), "");
83
84 // different year, month and day
85 static_assert( testComparisons2(
86 year_month_weekday_last{year{1234}, February, weekday_last{Wednesday}},
87 year_month_weekday_last{year{1235}, January, weekday_last{Tuesday}},
88 false), "");
89
90
91 // same year, different days
92 for (unsigned i = 1; i < 28; ++i)
93 for (unsigned j = 1; j < 28; ++j)
94 assert((testComparisons2(
95 year_month_weekday_last{year{1234}, January, weekday_last{weekday{i}}},
96 year_month_weekday_last{year{1234}, January, weekday_last{weekday{j}}},
97 i == j)));
98
99 // same year, different months
100 for (unsigned i = 1; i < 12; ++i)
101 for (unsigned j = 1; j < 12; ++j)
102 assert((testComparisons2(
103 year_month_weekday_last{year{1234}, month{i}, weekday_last{Tuesday}},
104 year_month_weekday_last{year{1234}, month{j}, weekday_last{Tuesday}},
105 i == j)));
106
107 // same month, different years
108 for (int i = 1000; i < 20; ++i)
109 for (int j = 1000; j < 20; ++j)
110 assert((testComparisons2(
111 year_month_weekday_last{year{i}, January, weekday_last{Tuesday}},
112 year_month_weekday_last{year{j}, January, weekday_last{Tuesday}},
113 i == j)));
114 }
115