xref: /llvm-project/libcxx/test/std/time/time.cal/time.cal.ymwdlast/time.cal.ymwdlast.members/ctor.pass.cpp (revision 7738db2c06b177fe916ac1bcf3633449b3c1fca9)
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 // class year_month_weekday_last;
12 
13 //  constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
14 //                               const chrono::weekday_last& wdl) noexcept;
15 //
16 //  Effects:  Constructs an object of type year_month_weekday_last by initializing
17 //                y_ with y, m_ with m, and wdl_ with wdl.
18 //
19 //  constexpr chrono::year                 year() const noexcept;
20 //  constexpr chrono::month               month() const noexcept;
21 //  constexpr chrono::weekday           weekday() const noexcept;
22 //  constexpr chrono::weekday_last weekday_last() const noexcept;
23 //  constexpr bool                           ok() const noexcept;
24 
25 #include <chrono>
26 #include <type_traits>
27 #include <cassert>
28 
29 #include "test_macros.h"
30 
main(int,char **)31 int main(int, char**)
32 {
33     using year                    = std::chrono::year;
34     using month                   = std::chrono::month;
35     using weekday                 = std::chrono::weekday;
36     using weekday_last            = std::chrono::weekday_last;
37     using year_month_weekday_last = std::chrono::year_month_weekday_last;
38 
39     constexpr month January = std::chrono::January;
40     constexpr weekday Tuesday = std::chrono::Tuesday;
41 
42     ASSERT_NOEXCEPT(year_month_weekday_last{year{1}, month{1}, weekday_last{Tuesday}});
43 
44     constexpr year_month_weekday_last ym1{year{2019}, January, weekday_last{Tuesday}};
45     static_assert( ym1.year()         == year{2019},            "");
46     static_assert( ym1.month()        == January,               "");
47     static_assert( ym1.weekday()      == Tuesday,               "");
48     static_assert( ym1.weekday_last() == weekday_last{Tuesday}, "");
49     static_assert( ym1.ok(),                                    "");
50 
51 
52   return 0;
53 }
54