[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.hms / time.hms.members / hours.pass.cpp
blobce7591c78b5eb5470eceacd3d67b2dbe9e7fb4cc
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::hours hours() const noexcept;
16 // Test values
17 // duration hours minutes seconds fractional
18 // 5000s 1 23 20 0
19 // 5000 minutes 83 20 0 0
20 // 123456789ms 34 17 36 789ms
21 // 123456789us 0 2 3 456789us
22 // 123456789ns 0 0 0 123456789ns
23 // 1000mfn 0 20 9 0.6 (6000/10000)
24 // 10000mfn 3 21 36 0
27 #include <chrono>
28 #include <cassert>
29 #include <ratio>
30 #include <utility>
32 #include "test_macros.h"
34 template <typename Duration>
35 constexpr long check_hours(Duration d)
37 using HMS = std::chrono::hh_mm_ss<Duration>;
38 ASSERT_SAME_TYPE(std::chrono::hours, decltype(std::declval<HMS>().hours()));
39 ASSERT_NOEXCEPT( std::declval<HMS>().hours());
40 return HMS(d).hours().count();
43 int main(int, char**)
45 using microfortnights = std::chrono::duration<int, std::ratio<756, 625>>;
47 static_assert( check_hours(std::chrono::minutes( 1)) == 0, "");
48 static_assert( check_hours(std::chrono::minutes(-1)) == 0, "");
50 assert( check_hours(std::chrono::seconds( 5000)) == 1);
51 assert( check_hours(std::chrono::seconds(-5000)) == 1);
52 assert( check_hours(std::chrono::minutes( 5000)) == 83);
53 assert( check_hours(std::chrono::minutes(-5000)) == 83);
54 assert( check_hours(std::chrono::hours( 11)) == 11);
55 assert( check_hours(std::chrono::hours(-11)) == 11);
57 assert( check_hours(std::chrono::milliseconds( 123456789LL)) == 34);
58 assert( check_hours(std::chrono::milliseconds(-123456789LL)) == 34);
59 assert( check_hours(std::chrono::microseconds( 123456789LL)) == 0);
60 assert( check_hours(std::chrono::microseconds(-123456789LL)) == 0);
61 assert( check_hours(std::chrono::nanoseconds( 123456789LL)) == 0);
62 assert( check_hours(std::chrono::nanoseconds(-123456789LL)) == 0);
64 assert( check_hours(microfortnights( 1000)) == 0);
65 assert( check_hours(microfortnights( -1000)) == 0);
66 assert( check_hours(microfortnights( 10000)) == 3);
67 assert( check_hours(microfortnights(-10000)) == 3);
69 return 0;