Debian Codegraph @

libcxx/test/std/time/time.cal/time.cal.weekday/time.cal.weekday.members/increment.pass.cpp

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