Home | History | Annotate | Download | only in time.cal.ymwd.members
      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;
     13 
     14 //  year_month_weekday() = default;
     15 //  constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
     16 //                               const chrono::weekday_indexed& wdi) noexcept;
     17 //
     18 //  Effects:  Constructs an object of type year_month_weekday by initializing
     19 //                y_ with y, m_ with m, and wdi_ with wdi.
     20 //
     21 //  constexpr chrono::year                       year() const noexcept;
     22 //  constexpr chrono::month                     month() const noexcept;
     23 //  constexpr chrono::weekday                 weekday() const noexcept;
     24 //  constexpr unsigned                          index() const noexcept;
     25 //  constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
     26 //  constexpr bool                                 ok() const noexcept;
     27 
     28 #include <chrono>
     29 #include <type_traits>
     30 #include <cassert>
     31 
     32 #include "test_macros.h"
     33 
     34 int main()
     35 {
     36     using year               = std::chrono::year;
     37     using month              = std::chrono::month;
     38     using weekday            = std::chrono::weekday;
     39     using weekday_indexed    = std::chrono::weekday_indexed;
     40     using year_month_weekday = std::chrono::year_month_weekday;
     41 
     42     constexpr month January = std::chrono::January;
     43     constexpr weekday Tuesday = std::chrono::Tuesday;
     44 
     45     ASSERT_NOEXCEPT(year_month_weekday{});
     46     ASSERT_NOEXCEPT(year_month_weekday{year{1}, month{1}, weekday_indexed{Tuesday, 1}});
     47 
     48     constexpr year_month_weekday ym0{};
     49     static_assert( ym0.year()            == year{},            "");
     50     static_assert( ym0.month()           == month{},           "");
     51     static_assert( ym0.weekday()         == weekday{},         "");
     52     static_assert( ym0.index()           == 0,                 "");
     53     static_assert( ym0.weekday_indexed() == weekday_indexed{}, "");
     54     static_assert(!ym0.ok(),                                   "");
     55 
     56     constexpr year_month_weekday ym1{year{2019}, January, weekday_indexed{Tuesday, 1}};
     57     static_assert( ym1.year()            == year{2019},                  "");
     58     static_assert( ym1.month()           == January,                     "");
     59     static_assert( ym1.weekday()         == Tuesday,                     "");
     60     static_assert( ym1.index()           == 1,                           "");
     61     static_assert( ym1.weekday_indexed() == weekday_indexed{Tuesday, 1}, "");
     62     static_assert( ym1.ok(),                                             "");
     63 
     64 }
     65