• 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 day;
13 
14 //                     day() = default;
15 //  explicit constexpr day(unsigned d) noexcept;
16 //  explicit constexpr operator unsigned() const noexcept;
17 
18 //  Effects: Constructs an object of type day by initializing d_ with d.
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 day = std::chrono::day;
30 
31     ASSERT_NOEXCEPT(day{});
32     ASSERT_NOEXCEPT(day(0U));
33     ASSERT_NOEXCEPT(static_cast<unsigned>(day(0U)));
34 
35     constexpr day d0{};
36     static_assert(static_cast<unsigned>(d0) == 0, "");
37 
38     constexpr day d1{1};
39     static_assert(static_cast<unsigned>(d1) == 1, "");
40 
41     for (unsigned i = 0; i <= 255; ++i)
42     {
43         day day(i);
44         assert(static_cast<unsigned>(day) == i);
45     }
46 }
47