53 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710// UNSUPPORTED: no-filesystem, no-localization, no-tzdb11 12// XFAIL: libcpp-has-no-experimental-tzdb13// XFAIL: availability-tzdb-missing14 15// <chrono>16 17// class leap_second;18 19// constexpr seconds value() 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 29constexpr void test(const std::chrono::leap_second leap_second, std::chrono::seconds expected) {30 std::same_as<std::chrono::seconds> auto value = leap_second.value();31 assert(value == expected);32 static_assert(noexcept(leap_second.value()));33}34 35constexpr bool test() {36 test(test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}),37 std::chrono::seconds{1});38 39 return true;40}41 42int main(int, const char**) {43 test();44 static_assert(test());45 46 // test with the real tzdb47 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].value());50 51 return 0;52}53