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 weekday;
12
13// constexpr weekday& operator+=(const days& d) noexcept;
14// constexpr weekday& operator-=(const days& d) noexcept;
15
16#include <chrono>
17#include <cassert>
18#include <type_traits>
19#include <utility>
20
21#include "test_macros.h"
22#include "../../euclidian.h"
23
24using weekday = std::chrono::weekday;
25using days = std::chrono::days;
26
27constexpr bool test() {
28 for (unsigned i = 0; i <= 6; ++i) {
29 weekday wd(i);
30 assert(((wd += days{3}).c_encoding() == euclidian_addition<unsigned, 0, 6>(i, 3)));
31 assert(((wd).c_encoding() == euclidian_addition<unsigned, 0, 6>(i, 3)));
32 }
33
34 for (unsigned i = 0; i <= 6; ++i) {
35 weekday wd(i);
36 assert(((wd -= days{4}).c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
37 assert(((wd).c_encoding() == euclidian_subtraction<unsigned, 0, 6>(i, 4)));
38 }
39
40 return true;
41}
42
43int main(int, char**) {
44 ASSERT_NOEXCEPT(std::declval<weekday&>() += std::declval<days&>());
45 ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() += std::declval<days&>()));
46
47 ASSERT_NOEXCEPT(std::declval<weekday&>() -= std::declval<days&>());
48 ASSERT_SAME_TYPE(weekday&, decltype(std::declval<weekday&>() -= std::declval<days&>()));
49
50 test();
51 static_assert(test());
52
53 return 0;
54}
55

source code of libcxx/test/std/time/time.cal/time.cal.weekday/time.cal.weekday.members/plus_minus_equal.pass.cpp