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 month January{1};
13 // inline constexpr month February{2};
14 // inline constexpr month March{3};
15 // inline constexpr month April{4};
16 // inline constexpr month May{5};
17 // inline constexpr month June{6};
18 // inline constexpr month July{7};
19 // inline constexpr month August{8};
20 // inline constexpr month September{9};
21 // inline constexpr month October{10};
22 // inline constexpr month November{11};
23 // inline constexpr month December{12};
24
25
26 #include <chrono>
27 #include <type_traits>
28 #include <cassert>
29
30 #include "test_macros.h"
31
main(int,char **)32 int main(int, char**)
33 {
34
35 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::January));
36 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::February));
37 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::March));
38 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::April));
39 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::May));
40 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::June));
41 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::July));
42 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::August));
43 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::September));
44 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::October));
45 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::November));
46 ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::December));
47
48 static_assert( std::chrono::January == std::chrono::month(1), "");
49 static_assert( std::chrono::February == std::chrono::month(2), "");
50 static_assert( std::chrono::March == std::chrono::month(3), "");
51 static_assert( std::chrono::April == std::chrono::month(4), "");
52 static_assert( std::chrono::May == std::chrono::month(5), "");
53 static_assert( std::chrono::June == std::chrono::month(6), "");
54 static_assert( std::chrono::July == std::chrono::month(7), "");
55 static_assert( std::chrono::August == std::chrono::month(8), "");
56 static_assert( std::chrono::September == std::chrono::month(9), "");
57 static_assert( std::chrono::October == std::chrono::month(10), "");
58 static_assert( std::chrono::November == std::chrono::month(11), "");
59 static_assert( std::chrono::December == std::chrono::month(12), "");
60
61 assert(std::chrono::January == std::chrono::month(1));
62 assert(std::chrono::February == std::chrono::month(2));
63 assert(std::chrono::March == std::chrono::month(3));
64 assert(std::chrono::April == std::chrono::month(4));
65 assert(std::chrono::May == std::chrono::month(5));
66 assert(std::chrono::June == std::chrono::month(6));
67 assert(std::chrono::July == std::chrono::month(7));
68 assert(std::chrono::August == std::chrono::month(8));
69 assert(std::chrono::September == std::chrono::month(9));
70 assert(std::chrono::October == std::chrono::month(10));
71 assert(std::chrono::November == std::chrono::month(11));
72 assert(std::chrono::December == std::chrono::month(12));
73
74 assert(static_cast<unsigned>(std::chrono::January) == 1);
75 assert(static_cast<unsigned>(std::chrono::February) == 2);
76 assert(static_cast<unsigned>(std::chrono::March) == 3);
77 assert(static_cast<unsigned>(std::chrono::April) == 4);
78 assert(static_cast<unsigned>(std::chrono::May) == 5);
79 assert(static_cast<unsigned>(std::chrono::June) == 6);
80 assert(static_cast<unsigned>(std::chrono::July) == 7);
81 assert(static_cast<unsigned>(std::chrono::August) == 8);
82 assert(static_cast<unsigned>(std::chrono::September) == 9);
83 assert(static_cast<unsigned>(std::chrono::October) == 10);
84 assert(static_cast<unsigned>(std::chrono::November) == 11);
85 assert(static_cast<unsigned>(std::chrono::December) == 12);
86
87 return 0;
88 }
89