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