Debian Codegraph @

libcxx/test/std/time/time.zone/time.zone.leap/members/value.pass.cpp

raw
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 seconds value() const noexcept;
20
21 #include <cassert>
22 #include <chrono>
23
24 #include "test_macros.h"
25
26 #include "test_chrono_leap_second.h"
27
28 constexpr void test(const std::chrono::leap_second leap_second, std::chrono::seconds expected) {
29 std::same_as<std::chrono::seconds> auto value = leap_second.value();
30 assert(value == expected);
31 static_assert(noexcept(leap_second.value()));
32 }
33
34 constexpr bool test() {
35 test(test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}),
36 std::chrono::seconds{1});
37
38 return true;
39 }
40
41 int main(int, const char**) {
42 test();
43 static_assert(test());
44
45 // test with the real tzdb
46 const std::chrono::tzdb& tzdb = std::chrono::get_tzdb();
47 assert(!tzdb.leap_seconds.empty());
48 test(tzdb.leap_seconds[0], tzdb.leap_seconds[0].value());
49
50 return 0;
51 }