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