[FMV][AArch64] Changes in fmv-features metadata. (#122192)
[llvm-project.git] / libcxx / test / std / time / time.hms / time.hms.members / seconds.pass.cpp
blobf0723be01a74c7d5855fa558967722d229f6ef73
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 // <chrono>
11 // template <class Duration>
12 // class hh_mm_ss
14 // constexpr chrono::seconds seconds() const noexcept;
16 // See the table in hours.pass.cpp for correspondence between the magic values used below
18 #include <chrono>
19 #include <cassert>
20 #include <cstdint>
21 #include <ratio>
22 #include <utility>
24 #include "test_macros.h"
26 template <typename Duration>
27 constexpr std::int64_t check_seconds(Duration d)
29 using HMS = std::chrono::hh_mm_ss<Duration>;
30 ASSERT_SAME_TYPE(std::chrono::seconds, decltype(std::declval<HMS>().seconds()));
31 ASSERT_NOEXCEPT( std::declval<HMS>().seconds());
32 return HMS(d).seconds().count();
35 int main(int, char**)
37 using microfortnights = std::chrono::duration<int, std::ratio<756, 625>>;
39 static_assert( check_seconds(std::chrono::seconds( 1)) == 1, "");
40 static_assert( check_seconds(std::chrono::seconds(-1)) == 1, "");
42 assert( check_seconds(std::chrono::seconds( 5000)) == 20);
43 assert( check_seconds(std::chrono::seconds(-5000)) == 20);
44 assert( check_seconds(std::chrono::minutes( 5000)) == 0);
45 assert( check_seconds(std::chrono::minutes(-5000)) == 0);
46 assert( check_seconds(std::chrono::hours( 11)) == 0);
47 assert( check_seconds(std::chrono::hours(-11)) == 0);
49 assert( check_seconds(std::chrono::milliseconds( 123456789LL)) == 36);
50 assert( check_seconds(std::chrono::milliseconds(-123456789LL)) == 36);
51 assert( check_seconds(std::chrono::microseconds( 123456789LL)) == 3);
52 assert( check_seconds(std::chrono::microseconds(-123456789LL)) == 3);
53 assert( check_seconds(std::chrono::nanoseconds( 123456789LL)) == 0);
54 assert( check_seconds(std::chrono::nanoseconds(-123456789LL)) == 0);
56 assert( check_seconds(microfortnights( 1000)) == 9);
57 assert( check_seconds(microfortnights( -1000)) == 9);
58 assert( check_seconds(microfortnights( 10000)) == 36);
59 assert( check_seconds(microfortnights(-10000)) == 36);
61 return 0;