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

source code of libcxx/test/std/time/time.cal/time.cal.day/time.cal.day.nonmembers/comparisons.pass.cpp