| 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 year; |
| 12 |
|
| 13 |
// constexpr bool operator==(const year& x, const year& y) noexcept; |
| 14 |
// constexpr strong_ordering operator<=>(const year& x, const year& 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 year = std::chrono::year; |
| 25 |
|
| 26 |
// Validate valid value. The range [-32768, 32767] is guaranteed to be allowed. |
| 27 |
assert(testOrderValues<year>(-32768, -32768)); |
| 28 |
assert(testOrderValues<year>(-32768, -32767)); |
| 29 |
// Largest positive |
| 30 |
assert(testOrderValues<year>(32767, 32766)); |
| 31 |
assert(testOrderValues<year>(32767, 32767)); |
| 32 |
|
| 33 |
// Validate some valid values. |
| 34 |
for (int i = 1; i < 10; ++i) |
| 35 |
for (int j = 1; j < 10; ++j) |
| 36 |
assert(testOrderValues<year>(i, j)); |
| 37 |
|
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
int main(int, char**) { |
| 42 |
using year = std::chrono::year; |
| 43 |
AssertOrderAreNoexcept<year>(); |
| 44 |
AssertOrderReturn<std::strong_ordering, year>(); |
| 45 |
|
| 46 |
test(); |
| 47 |
static_assert(test()); |
| 48 |
|
| 49 |
return 0; |
| 50 |
} |