Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / time / time.zone / time.zone.zonedtime / time.zone.zonedtime.members / operator_sys_time.pass.cpp
blob68d8a15ec98892c359f2635a35ea29866d148ffa
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: no-filesystem, no-localization, no-tzdb
12 // XFAIL: libcpp-has-no-experimental-tzdb
13 // XFAIL: availability-tzdb-missing
15 // <chrono>
17 // template<class Duration, class TimeZonePtr = const time_zone*>
18 // class zoned_time;
20 // operator sys_time<duration>() const;
22 #include <chrono>
23 #include <cassert>
24 #include <concepts>
26 #include "../test_offset_time_zone.h"
28 namespace cr = std::chrono;
30 static void test_const_member() {
32 using duration = cr::nanoseconds;
33 using time_point = cr::sys_time<duration>;
34 static_assert(std::is_convertible_v<time_point, cr::zoned_time<duration>>);
35 cr::zoned_time<duration> zt{time_point{duration{42}}};
37 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
38 assert(time == time_point{duration{42}});
41 using duration = cr::nanoseconds;
42 using time_point = cr::sys_time<duration>;
43 static_assert(std::is_convertible_v<time_point, const cr::zoned_time<duration>>);
44 const cr::zoned_time<duration> zt{time_point{duration{42}}};
46 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
47 assert(time == time_point{duration{42}});
51 static void test_duration_conversion() {
52 // common_type_t<duration, seconds> -> duration
54 using duration = cr::nanoseconds;
55 using time_point = cr::sys_time<duration>;
56 cr::zoned_time<duration> zt{time_point{duration{42}}};
58 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
59 assert(time == time_point{duration{42}});
62 using duration = cr::microseconds;
63 using time_point = cr::sys_time<duration>;
64 cr::zoned_time<duration> zt{time_point{duration{42}}};
66 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
67 assert(time == time_point{duration{42}});
70 using duration = cr::milliseconds;
71 using time_point = cr::sys_time<duration>;
72 cr::zoned_time<duration> zt{time_point{duration{42}}};
74 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
75 assert(time == time_point{duration{42}});
77 // common_type_t<seconds, seconds> -> seconds
79 using duration = cr::seconds;
80 using time_point = cr::sys_time<duration>;
81 cr::zoned_time<duration> zt{time_point{duration{42}}};
83 std::same_as<time_point> decltype(auto) time = static_cast<time_point>(zt);
84 assert(time == time_point{duration{42}});
86 // common_type_t<duration, seconds> -> seconds
88 using duration = cr::days;
89 using time_point = cr::sys_time<duration>;
90 cr::zoned_time<duration> zt{time_point{duration{42}}};
92 std::same_as<cr::sys_seconds> decltype(auto) time = static_cast<cr::sys_seconds>(zt);
93 assert(time == time_point{duration{42}});
96 using duration = cr::weeks;
97 using time_point = cr::sys_time<duration>;
98 cr::zoned_time<duration> zt{time_point{duration{42}}};
100 std::same_as<cr::sys_seconds> decltype(auto) time = static_cast<cr::sys_seconds>(zt);
101 assert(time == time_point{duration{42}});
104 using duration = cr::months;
105 using time_point = cr::sys_time<duration>;
106 cr::zoned_time<duration> zt{time_point{duration{42}}};
108 std::same_as<cr::sys_seconds> decltype(auto) time = static_cast<cr::sys_seconds>(zt);
109 assert(time == time_point{duration{42}});
112 using duration = cr::years;
113 using time_point = cr::sys_time<duration>;
114 cr::zoned_time<duration> zt{time_point{duration{42}}};
116 std::same_as<cr::sys_seconds> decltype(auto) time = static_cast<cr::sys_seconds>(zt);
117 assert(time == time_point{duration{42}});
121 int main(int, char**) {
122 test_const_member();
123 test_duration_conversion();
125 return 0;