| 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 | // REQUIRES: std-at-least-c++20 |
| 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 gps_clock { |
| 18 | // public: |
| 19 | // using rep = a signed arithmetic type; |
| 20 | // using period = ratio<unspecified, unspecified>; |
| 21 | // using duration = chrono::duration<rep, period>; |
| 22 | // using time_point = chrono::time_point<gps_clock>; |
| 23 | // static constexpr bool is_steady = unspecified; |
| 24 | // |
| 25 | // ... |
| 26 | // }; |
| 27 | // |
| 28 | // template<class Duration> |
| 29 | // using gps_time = time_point<gps_clock, Duration>; |
| 30 | // using gps_seconds = gps_time<seconds>; |
| 31 | |
| 32 | #include <chrono> |
| 33 | #include <concepts> |
| 34 | #include <ratio> |
| 35 | |
| 36 | #include "test_macros.h" |
| 37 | |
| 38 | // class gps_clock |
| 39 | using rep = std::chrono::gps_clock::rep; |
| 40 | using period = std::chrono::gps_clock::period; |
| 41 | using duration = std::chrono::gps_clock::duration; |
| 42 | using time_point = std::chrono::gps_clock::time_point; |
| 43 | [[maybe_unused]] constexpr bool is_steady = std::chrono::gps_clock::is_steady; |
| 44 | |
| 45 | // Tests the values. part of them are implementation defined. |
| 46 | LIBCPP_STATIC_ASSERT(std::same_as<rep, std::chrono::utc_clock::rep>); |
| 47 | static_assert(std::is_arithmetic_v<rep>); |
| 48 | static_assert(std::is_signed_v<rep>); |
| 49 | |
| 50 | LIBCPP_STATIC_ASSERT(std::same_as<period, std::chrono::utc_clock::period>); |
| 51 | static_assert(std::same_as<period, std::ratio<period::num, period::den>>); |
| 52 | |
| 53 | static_assert(std::same_as<duration, std::chrono::duration<rep, period>>); |
| 54 | static_assert(std::same_as<time_point, std::chrono::time_point<std::chrono::gps_clock>>); |
| 55 | LIBCPP_STATIC_ASSERT(is_steady == false); |
| 56 | |
| 57 | // typedefs |
| 58 | static_assert(std::same_as<std::chrono::gps_time<int>, std::chrono::time_point<std::chrono::gps_clock, int>>); |
| 59 | static_assert(std::same_as<std::chrono::gps_time<long>, std::chrono::time_point<std::chrono::gps_clock, long>>); |
| 60 | static_assert(std::same_as<std::chrono::gps_seconds, std::chrono::gps_time<std::chrono::seconds>>); |
| 61 | |