• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
10 
11 // <chrono>
12 // class month;
13 
14 //                     month() = default;
15 //  explicit constexpr month(int m) noexcept;
16 //  explicit constexpr operator int() const noexcept;
17 
18 //  Effects: Constructs an object of type month by initializing m_ with m.
19 //    The value held is unspecified if d is not in the range [0, 255].
20 
21 #include <chrono>
22 #include <type_traits>
23 #include <cassert>
24 
25 #include "test_macros.h"
26 
main()27 int main()
28 {
29     using month = std::chrono::month;
30 
31     ASSERT_NOEXCEPT(month{});
32     ASSERT_NOEXCEPT(month(1));
33     ASSERT_NOEXCEPT(static_cast<unsigned>(month(1)));
34 
35     constexpr month m0{};
36     static_assert(static_cast<unsigned>(m0) == 0, "");
37 
38     constexpr month m1{1};
39     static_assert(static_cast<unsigned>(m1) == 1, "");
40 
41     for (unsigned i = 0; i <= 255; ++i)
42     {
43         month m(i);
44         assert(static_cast<unsigned>(m) == i);
45     }
46 }
47