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 weekday; 13 14 // constexpr weekday_indexed operator[](unsigned index) const noexcept; 15 // constexpr weekday_last operator[](last_spec) const noexcept; 16 17 18 #include <chrono> 19 #include <type_traits> 20 #include <cassert> 21 22 #include "test_macros.h" 23 #include "../../euclidian.h" 24 main()25int main() 26 { 27 using weekday = std::chrono::weekday; 28 using weekday_last = std::chrono::weekday_last; 29 using weekday_indexed = std::chrono::weekday_indexed; 30 31 constexpr weekday Sunday = std::chrono::Sunday; 32 33 ASSERT_NOEXCEPT( std::declval<weekday>()[1U]); 34 ASSERT_SAME_TYPE(weekday_indexed, decltype(std::declval<weekday>()[1U])); 35 36 ASSERT_NOEXCEPT( std::declval<weekday>()[std::chrono::last]); 37 ASSERT_SAME_TYPE(weekday_last, decltype(std::declval<weekday>()[std::chrono::last])); 38 39 static_assert(Sunday[2].weekday() == Sunday, ""); 40 static_assert(Sunday[2].index () == 2, ""); 41 42 for (unsigned i = 0; i <= 6; ++i) 43 { 44 weekday wd(i); 45 weekday_last wdl = wd[std::chrono::last]; 46 assert(wdl.weekday() == wd); 47 assert(wdl.ok()); 48 } 49 50 for (unsigned i = 0; i <= 6; ++i) 51 for (unsigned j = 1; j <= 5; ++j) 52 { 53 weekday wd(i); 54 weekday_indexed wdi = wd[j]; 55 assert(wdi.weekday() == wd); 56 assert(wdi.index() == j); 57 assert(wdi.ok()); 58 } 59 } 60