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 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 // UNSUPPORTED: no-filesystem, no-localization, no-tzdb 11 12 // XFAIL: libcpp-has-no-experimental-tzdb 13 // XFAIL: availability-tzdb-missing 14 15 // <chrono> 16 17 // class leap_second; 18 19 // constexpr sys_seconds date() const noexcept; 20 21 #include <cassert> 22 #include <chrono> 23 #include <concepts> 24 25 #include "test_macros.h" 26 27 #include "test_chrono_leap_second.h" 28 29 constexpr void test(const std::chrono::leap_second leap_second, std::chrono::sys_seconds expected) { 30 std::same_as<std::chrono::sys_seconds> auto date = leap_second.date(); 31 assert(date == expected); 32 static_assert(noexcept(leap_second.date())); 33 } 34 35 constexpr bool test() { 36 test(test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}), 37 std::chrono::sys_seconds{std::chrono::seconds{0}}); 38 39 return true; 40 } 41 42 int main(int, const char**) { 43 test(); 44 static_assert(test()); 45 46 // test with the real tzdb 47 const std::chrono::tzdb& tzdb = std::chrono::get_tzdb(); 48 assert(!tzdb.leap_seconds.empty()); 49 test(tzdb.leap_seconds[0], tzdb.leap_seconds[0].date()); 50 51 return 0; 52 } 53