Debian Codegraph @

libcxx/test/std/time/time.cal/time.cal.mwdlast/time.cal.mwdlast.members/ctor.pass.cpp

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