[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.weekday / time.cal.weekday.nonmembers / minus.pass.cpp
blobef5753100f3a94d3b900be52399a503f1f384c34
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
10 // <chrono>
11 // class weekday;
13 // constexpr weekday operator-(const weekday& x, const days& y) noexcept;
14 // Returns: x + -y.
16 // constexpr days operator-(const weekday& x, const weekday& y) noexcept;
17 // Returns: If x.ok() == true and y.ok() == true, returns a value d in the range
18 // [days{0}, days{6}] satisfying y + d == x.
19 // Otherwise the value returned is unspecified.
20 // [Example: Sunday - Monday == days{6}. -end example]
22 #include <chrono>
23 #include <type_traits>
24 #include <cassert>
26 #include "test_macros.h"
27 #include "../../euclidian.h"
29 using weekday = std::chrono::weekday;
30 using days = std::chrono::days;
32 constexpr bool test() {
33 for (unsigned i = 0; i <= 6; ++i)
34 for (unsigned j = 0; j <= 6; ++j) {
35 weekday wd = weekday{i} - days{j};
36 assert(wd + days{j} == weekday{i});
37 assert((wd.c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, j)));
40 for (unsigned i = 0; i <= 6; ++i)
41 for (unsigned j = 0; j <= 6; ++j) {
42 days d = weekday{j} - weekday{i};
43 assert(weekday{i} + d == weekday{j});
46 // Check the example
47 assert(weekday{0} - weekday{1} == days{6});
49 return true;
52 int main(int, char**) {
53 ASSERT_NOEXCEPT(std::declval<weekday>() - std::declval<days>());
54 ASSERT_SAME_TYPE(weekday, decltype(std::declval<weekday>() - std::declval<days>()));
56 ASSERT_NOEXCEPT(std::declval<weekday>() - std::declval<weekday>());
57 ASSERT_SAME_TYPE(days, decltype(std::declval<weekday>() - std::declval<weekday>()));
59 test();
60 static_assert(test());
62 return 0;