• 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 weekday;
13 
14 //                     weekday() = default;
15 //  explicit constexpr weekday(unsigned wd) noexcept;
16 //  constexpr weekday(const sys_days& dp) noexcept;
17 //  explicit constexpr weekday(const local_days& dp) noexcept;
18 //
19 //  explicit constexpr operator unsigned() const noexcept;
20 
21 //  Effects: Constructs an object of type weekday by initializing m_ with m.
22 //    The value held is unspecified if d is not in the range [0, 255].
23 
24 #include <chrono>
25 #include <type_traits>
26 #include <cassert>
27 
28 #include "test_macros.h"
29 
main()30 int main()
31 {
32     using weekday = std::chrono::weekday;
33 
34     ASSERT_NOEXCEPT(weekday{});
35     ASSERT_NOEXCEPT(weekday(1));
36     ASSERT_NOEXCEPT(static_cast<unsigned>(weekday(1)));
37 
38     constexpr weekday m0{};
39     static_assert(static_cast<unsigned>(m0) == 0, "");
40 
41     constexpr weekday m1{1};
42     static_assert(static_cast<unsigned>(m1) == 1, "");
43 
44     for (unsigned i = 0; i <= 255; ++i)
45     {
46         weekday m(i);
47         assert(static_cast<unsigned>(m) == i);
48     }
49 
50 // TODO - sys_days and local_days ctor tests
51 }
52