Home | History | Annotate | Download | only in time.cal.weekday.nonmembers
      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 
     13 // inline constexpr weekday   Sunday{0};
     14 // inline constexpr weekday   Monday{1};
     15 // inline constexpr weekday   Tuesday{2};
     16 // inline constexpr weekday   Wednesday{3};
     17 // inline constexpr weekday   Thursday{4};
     18 // inline constexpr weekday   Friday{5};
     19 // inline constexpr weekday   Saturday{6};
     20 
     21 
     22 #include <chrono>
     23 #include <type_traits>
     24 #include <cassert>
     25 
     26 #include "test_macros.h"
     27 
     28 int main()
     29 {
     30 
     31     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Sunday));
     32     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Monday));
     33     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Tuesday));
     34     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Wednesday));
     35     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Thursday));
     36     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Friday));
     37     ASSERT_SAME_TYPE(const std::chrono::weekday, decltype(std::chrono::Saturday));
     38 
     39     static_assert( std::chrono::Sunday    == std::chrono::weekday(0),  "");
     40     static_assert( std::chrono::Monday    == std::chrono::weekday(1),  "");
     41     static_assert( std::chrono::Tuesday   == std::chrono::weekday(2),  "");
     42     static_assert( std::chrono::Wednesday == std::chrono::weekday(3),  "");
     43     static_assert( std::chrono::Thursday  == std::chrono::weekday(4),  "");
     44     static_assert( std::chrono::Friday    == std::chrono::weekday(5),  "");
     45     static_assert( std::chrono::Saturday  == std::chrono::weekday(6),  "");
     46 
     47     assert(std::chrono::Sunday    == std::chrono::weekday(0));
     48     assert(std::chrono::Monday    == std::chrono::weekday(1));
     49     assert(std::chrono::Tuesday   == std::chrono::weekday(2));
     50     assert(std::chrono::Wednesday == std::chrono::weekday(3));
     51     assert(std::chrono::Thursday  == std::chrono::weekday(4));
     52     assert(std::chrono::Friday    == std::chrono::weekday(5));
     53     assert(std::chrono::Saturday  == std::chrono::weekday(6));
     54 
     55     assert(static_cast<unsigned>(std::chrono::Sunday)    ==  0);
     56     assert(static_cast<unsigned>(std::chrono::Monday)    ==  1);
     57     assert(static_cast<unsigned>(std::chrono::Tuesday)   ==  2);
     58     assert(static_cast<unsigned>(std::chrono::Wednesday) ==  3);
     59     assert(static_cast<unsigned>(std::chrono::Thursday)  ==  4);
     60     assert(static_cast<unsigned>(std::chrono::Friday)    ==  5);
     61     assert(static_cast<unsigned>(std::chrono::Saturday)  ==  6);
     62 }
     63