Debian Codegraph @

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