Home | History | Annotate | Download | only in time.cal.month.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 month January{1};
     14 // inline constexpr month February{2};
     15 // inline constexpr month March{3};
     16 // inline constexpr month April{4};
     17 // inline constexpr month May{5};
     18 // inline constexpr month June{6};
     19 // inline constexpr month July{7};
     20 // inline constexpr month August{8};
     21 // inline constexpr month September{9};
     22 // inline constexpr month October{10};
     23 // inline constexpr month November{11};
     24 // inline constexpr month December{12};
     25 
     26 
     27 #include <chrono>
     28 #include <type_traits>
     29 #include <cassert>
     30 
     31 #include "test_macros.h"
     32 
     33 int main()
     34 {
     35 
     36     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::January));
     37     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::February));
     38     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::March));
     39     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::April));
     40     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::May));
     41     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::June));
     42     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::July));
     43     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::August));
     44     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::September));
     45     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::October));
     46     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::November));
     47     ASSERT_SAME_TYPE(const std::chrono::month, decltype(std::chrono::December));
     48 
     49     static_assert( std::chrono::January   == std::chrono::month(1),  "");
     50     static_assert( std::chrono::February  == std::chrono::month(2),  "");
     51     static_assert( std::chrono::March     == std::chrono::month(3),  "");
     52     static_assert( std::chrono::April     == std::chrono::month(4),  "");
     53     static_assert( std::chrono::May       == std::chrono::month(5),  "");
     54     static_assert( std::chrono::June      == std::chrono::month(6),  "");
     55     static_assert( std::chrono::July      == std::chrono::month(7),  "");
     56     static_assert( std::chrono::August    == std::chrono::month(8),  "");
     57     static_assert( std::chrono::September == std::chrono::month(9),  "");
     58     static_assert( std::chrono::October   == std::chrono::month(10), "");
     59     static_assert( std::chrono::November  == std::chrono::month(11), "");
     60     static_assert( std::chrono::December  == std::chrono::month(12), "");
     61 
     62     assert(std::chrono::January   == std::chrono::month(1));
     63     assert(std::chrono::February  == std::chrono::month(2));
     64     assert(std::chrono::March     == std::chrono::month(3));
     65     assert(std::chrono::April     == std::chrono::month(4));
     66     assert(std::chrono::May       == std::chrono::month(5));
     67     assert(std::chrono::June      == std::chrono::month(6));
     68     assert(std::chrono::July      == std::chrono::month(7));
     69     assert(std::chrono::August    == std::chrono::month(8));
     70     assert(std::chrono::September == std::chrono::month(9));
     71     assert(std::chrono::October   == std::chrono::month(10));
     72     assert(std::chrono::November  == std::chrono::month(11));
     73     assert(std::chrono::December  == std::chrono::month(12));
     74 
     75     assert(static_cast<unsigned>(std::chrono::January)   ==  1);
     76     assert(static_cast<unsigned>(std::chrono::February)  ==  2);
     77     assert(static_cast<unsigned>(std::chrono::March)     ==  3);
     78     assert(static_cast<unsigned>(std::chrono::April)     ==  4);
     79     assert(static_cast<unsigned>(std::chrono::May)       ==  5);
     80     assert(static_cast<unsigned>(std::chrono::June)      ==  6);
     81     assert(static_cast<unsigned>(std::chrono::July)      ==  7);
     82     assert(static_cast<unsigned>(std::chrono::August)    ==  8);
     83     assert(static_cast<unsigned>(std::chrono::September) ==  9);
     84     assert(static_cast<unsigned>(std::chrono::October)   == 10);
     85     assert(static_cast<unsigned>(std::chrono::November)  == 11);
     86     assert(static_cast<unsigned>(std::chrono::December)  == 12);
     87 }
     88