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 month_weekday_last;
13
14 // constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
15 // Returns: x.month() == y.month()
16 //
17 // constexpr bool operator< (const month_weekday_last& x, const month_weekday_last& y) noexcept;
18 // Returns: x.month() < y.month()
19
20
21 #include <chrono>
22 #include <type_traits>
23 #include <cassert>
24
25 #include "test_macros.h"
26 #include "test_comparisons.h"
27
main()28 int main()
29 {
30 using month = std::chrono::month;
31 using weekday_last = std::chrono::weekday_last;
32 using weekday = std::chrono::weekday;
33 using month_weekday_last = std::chrono::month_weekday_last;
34
35 constexpr month January = std::chrono::January;
36 constexpr weekday Tuesday = std::chrono::Tuesday;
37 constexpr weekday Wednesday = std::chrono::Wednesday;
38
39 AssertComparisons2AreNoexcept<month_weekday_last>();
40 AssertComparisons2ReturnBool<month_weekday_last>();
41
42 static_assert( testComparisons2(
43 month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
44 month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
45 true), "");
46
47 static_assert( testComparisons2(
48 month_weekday_last{std::chrono::January, weekday_last{Tuesday}},
49 month_weekday_last{std::chrono::January, weekday_last{Wednesday}},
50 false), "");
51
52 // vary the months
53 for (unsigned i = 1; i < 12; ++i)
54 for (unsigned j = 1; j < 12; ++j)
55 assert((testComparisons2(
56 month_weekday_last{month{i}, weekday_last{Tuesday}},
57 month_weekday_last{month{j}, weekday_last{Tuesday}},
58 i == j)));
59
60 // vary the weekday
61 for (unsigned i = 0; i < 6; ++i)
62 for (unsigned j = 0; j < 6; ++j)
63 assert((testComparisons2(
64 month_weekday_last{January, weekday_last{weekday{i}}},
65 month_weekday_last{January, weekday_last{weekday{j}}},
66 i == j)));
67
68 // both different
69 assert((testComparisons2(
70 month_weekday_last{month{1}, weekday_last{weekday{1}}},
71 month_weekday_last{month{2}, weekday_last{weekday{2}}},
72 false)));
73 }
74