| 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; |
| 12 | |
| 13 | // constexpr bool operator==(const month& x, const month& y) noexcept; |
| 14 | // constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; |
| 15 | |
| 16 | #include <chrono> |
| 17 | #include <type_traits> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "test_macros.h" |
| 21 | #include "test_comparisons.h" |
| 22 | |
| 23 | constexpr bool test() { |
| 24 | using month = std::chrono::month; |
| 25 | |
| 26 | // Validate invalid values. The range [0, 255] is guaranteed to be allowed. |
| 27 | assert(testOrderValues<month>(0U, 0U)); |
| 28 | assert(testOrderValues<month>(0U, 1U)); |
| 29 | assert(testOrderValues<month>(254U, 255U)); |
| 30 | assert(testOrderValues<month>(255U, 255U)); |
| 31 | |
| 32 | // Validate some valid values. |
| 33 | for (unsigned i = 1; i <= 12; ++i) |
| 34 | for (unsigned j = 1; j <= 12; ++j) |
| 35 | assert(testOrderValues<month>(i, j)); |
| 36 | |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | int main(int, char**) { |
| 41 | using month = std::chrono::month; |
| 42 | AssertOrderAreNoexcept<month>(); |
| 43 | AssertOrderReturn<std::strong_ordering, month>(); |
| 44 | |
| 45 | test(); |
| 46 | static_assert(test()); |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |