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 
16 #include <chrono>
17 #include <type_traits>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
22 template <typename WD>
testConstexpr()23 constexpr bool testConstexpr()
24 {
25     WD wd{5};
26     return wd.c_encoding() == 5;
27 }
28 
main(int,char **)29 int main(int, char**)
30 {
31     using weekday = std::chrono::weekday;
32 
33     ASSERT_NOEXCEPT(                    std::declval<weekday&>().c_encoding());
34     ASSERT_SAME_TYPE(unsigned, decltype(std::declval<weekday&>().c_encoding()));
35 
36     static_assert(testConstexpr<weekday>(), "");
37 
38     for (unsigned i = 0; i <= 10; ++i)
39     {
40         weekday wd(i);
41         assert(wd.c_encoding() == (i == 7 ? 0 : i));
42     }
43 
44   return 0;
45 }
46