• 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_weekday_last;
13 
14 //  constexpr month_weekday_last(const chrono::month& m,
15 //                               const chrono::weekday_last& wdl) noexcept;
16 //
17 //  Effects:  Constructs an object of type month_weekday_last by
18 //            initializing m_ with m, and wdl_ with wdl.
19 //
20 //     constexpr chrono::month        month() const noexcept;
21 //     constexpr chrono::weekday_last weekday_last()  const noexcept;
22 //     constexpr bool                 ok()    const noexcept;
23 
24 
25 #include <chrono>
26 #include <type_traits>
27 #include <cassert>
28 
29 #include "test_macros.h"
30 
main()31 int main()
32 {
33     using month              = std::chrono::month;
34     using weekday            = std::chrono::weekday;
35     using weekday_last       = std::chrono::weekday_last;
36     using month_weekday_last = std::chrono::month_weekday_last;
37 
38     constexpr month January = std::chrono::January;
39     constexpr weekday Tuesday = std::chrono::Tuesday;
40 
41     ASSERT_NOEXCEPT(month_weekday_last{January, weekday_last{Tuesday}});
42 
43 //  bad month
44     constexpr month_weekday_last mwdl1{month{}, weekday_last{Tuesday}};
45     static_assert( mwdl1.month() == month{},                      "");
46     static_assert( mwdl1.weekday_last() == weekday_last{Tuesday}, "");
47     static_assert(!mwdl1.ok(),                                    "");
48 
49 //  bad weekday_last
50     constexpr month_weekday_last mwdl2{January, weekday_last{weekday{16}}};
51     static_assert( mwdl2.month() == January,                          "");
52     static_assert( mwdl2.weekday_last() == weekday_last{weekday{16}}, "");
53     static_assert(!mwdl2.ok(),                                        "");
54 
55 //  Good month and weekday_last
56     constexpr month_weekday_last mwdl3{January, weekday_last{weekday{4}}};
57     static_assert( mwdl3.month() == January,                         "");
58     static_assert( mwdl3.weekday_last() == weekday_last{weekday{4}}, "");
59     static_assert( mwdl3.ok(),                                       "");
60 }
61