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
12 // inline constexpr weekday Sunday{0};
13 // inline constexpr weekday Monday{1};
14 // inline constexpr weekday Tuesday{2};
15 // inline constexpr weekday Wednesday{3};
16 // inline constexpr weekday Thursday{4};
17 // inline constexpr weekday Friday{5};
18 // inline constexpr weekday Saturday{6};
19
20
21 #include <chrono>
22 #include <type_traits>
23 #include <cassert>
24
25 #include "test_macros.h"
26
main(int,char **)27 int main(int, char**)
28 {
29
30 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Sunday));
31 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Monday));
32 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Tuesday));
33 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Wednesday));
34 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Thursday));
35 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Friday));
36 ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Saturday));
37
38 static_assert( std::chrono::Sunday == std::chrono::weekday(0), "");
39 static_assert( std::chrono::Monday == std::chrono::weekday(1), "");
40 static_assert( std::chrono::Tuesday == std::chrono::weekday(2), "");
41 static_assert( std::chrono::Wednesday == std::chrono::weekday(3), "");
42 static_assert( std::chrono::Thursday == std::chrono::weekday(4), "");
43 static_assert( std::chrono::Friday == std::chrono::weekday(5), "");
44 static_assert( std::chrono::Saturday == std::chrono::weekday(6), "");
45
46 assert(std::chrono::Sunday == std::chrono::weekday(0));
47 assert(std::chrono::Monday == std::chrono::weekday(1));
48 assert(std::chrono::Tuesday == std::chrono::weekday(2));
49 assert(std::chrono::Wednesday == std::chrono::weekday(3));
50 assert(std::chrono::Thursday == std::chrono::weekday(4));
51 assert(std::chrono::Friday == std::chrono::weekday(5));
52 assert(std::chrono::Saturday == std::chrono::weekday(6));
53
54 assert(std::chrono::Sunday.c_encoding() == 0);
55 assert(std::chrono::Monday.c_encoding() == 1);
56 assert(std::chrono::Tuesday.c_encoding() == 2);
57 assert(std::chrono::Wednesday.c_encoding() == 3);
58 assert(std::chrono::Thursday.c_encoding() == 4);
59 assert(std::chrono::Friday.c_encoding() == 5);
60 assert(std::chrono::Saturday.c_encoding() == 6);
61
62 return 0;
63 }
64