Debian Codegraph @

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