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