Debian Codegraph @

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