]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/utilities/time/time.cal/time.cal.ymwdlast/time.cal.ymwdlast.members/ctor.pass.cpp
Vendor import of libc++ trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / std / utilities / time / time.cal / time.cal.ymwdlast / time.cal.ymwdlast.members / ctor.pass.cpp
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 year_month_weekday_last;
13
14 //  constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
15 //                               const chrono::weekday_last& wdl) noexcept;
16 //
17 //  Effects:  Constructs an object of type year_month_weekday_last by initializing
18 //                y_ with y, m_ with m, and wdl_ with wdl.
19 //
20 //  constexpr chrono::year                 year() const noexcept;
21 //  constexpr chrono::month               month() const noexcept;
22 //  constexpr chrono::weekday           weekday() const noexcept;
23 //  constexpr chrono::weekday_last weekday_last() const noexcept;
24 //  constexpr bool                           ok() const noexcept;
25
26 #include <chrono>
27 #include <type_traits>
28 #include <cassert>
29
30 #include "test_macros.h"
31
32 int main()
33 {
34     using year                    = std::chrono::year;
35     using month                   = std::chrono::month;
36     using weekday                 = std::chrono::weekday;
37     using weekday_last            = std::chrono::weekday_last;
38     using year_month_weekday_last = std::chrono::year_month_weekday_last;
39
40     constexpr month January = std::chrono::January;
41     constexpr weekday Tuesday = std::chrono::Tuesday;
42
43     ASSERT_NOEXCEPT(year_month_weekday_last{year{1}, month{1}, weekday_last{Tuesday}});
44
45     constexpr year_month_weekday_last ym1{year{2019}, January, weekday_last{Tuesday}};
46     static_assert( ym1.year()         == year{2019},            "");
47     static_assert( ym1.month()        == January,               "");
48     static_assert( ym1.weekday()      == Tuesday,               "");
49     static_assert( ym1.weekday_last() == weekday_last{Tuesday}, "");
50     static_assert( ym1.ok(),                                    "");
51
52 }