| 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 |
// leap_second(const leap_second&) = default; |
| 20 |
// |
| 21 |
// ... |
| 22 |
// }; |
| 23 |
|
| 24 |
#include <chrono> |
| 25 |
#include <concepts> |
| 26 |
#include <cassert> |
| 27 |
|
| 28 |
#include "test_chrono_leap_second.h" |
| 29 |
|
| 30 |
constexpr bool test() { |
| 31 |
std::chrono::leap_second a = |
| 32 |
test_leap_second_create(std::chrono::sys_seconds{std::chrono::seconds{0}}, std::chrono::seconds{1}); |
| 33 |
|
| 34 |
{ |
| 35 |
std::chrono::leap_second b = a; |
| 36 |
|
| 37 |
// operator== only compares the date member. |
| 38 |
assert(a.date() == b.date()); |
| 39 |
assert(a.value() == b.value()); |
| 40 |
} |
| 41 |
|
| 42 |
#ifdef _LIBCPP_VERSION |
| 43 |
{ |
| 44 |
// Tests an rvalue uses the copy constructor. |
| 45 |
// Since implementations are allowed to add additional constructors this is |
| 46 |
// a libc++ specific test. |
| 47 |
std::chrono::leap_second b = std::move(a); |
| 48 |
|
| 49 |
// operator== only compares the date member. |
| 50 |
assert(a.date() == b.date()); |
| 51 |
assert(a.value() == b.value()); |
| 52 |
} |
| 53 |
// libc++ does not provide a default constructor. |
| 54 |
static_assert(!std::is_default_constructible_v<std::chrono::leap_second>); |
| 55 |
#endif // _LIBCPP_VERSION |
| 56 |
|
| 57 |
return true; |
| 58 |
} |
| 59 |
|
| 60 |
int main(int, const char**) { |
| 61 |
static_assert(std::copy_constructible<std::chrono::leap_second>); |
| 62 |
|
| 63 |
test(); |
| 64 |
static_assert(test()); |
| 65 |
|
| 66 |
return 0; |
| 67 |
} |