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 weekday; 12 13 // constexpr unsigned iso_encoding() const noexcept; 14 // Returns the underlying weekday, _except_ that returns '7' for Sunday (zero) 15 // See [time.cal.wd.members] 16 17 #include <chrono> 18 #include <type_traits> 19 #include <cassert> 20 21 #include "test_macros.h" 22 23 template <typename WD> 24 constexpr bool testConstexpr() 25 { 26 WD wd{5}; 27 return wd.c_encoding() == 5; 28 } 29 30 int main(int, char**) 31 { 32 using weekday = std::chrono::weekday; 33 34 ASSERT_NOEXCEPT( std::declval<weekday&>().iso_encoding()); 35 ASSERT_SAME_TYPE(unsigned, decltype(std::declval<weekday&>().iso_encoding())); 36 37 static_assert(testConstexpr<weekday>(), ""); 38 39 // This is different than all the other tests, because the '7' gets converted to 40 // a zero in the constructor, but then back to '7' by iso_encoding(). 41 for (unsigned i = 0; i <= 10; ++i) 42 { 43 weekday wd(i); 44 assert(wd.iso_encoding() == (i == 0 ? 7 : i)); 45 } 46 47 return 0; 48 } 49