[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / time / time.duration / time.duration.cast / round.pass.cpp
blob8eb54a02162782d60b078f2ba1c09d0f0ec19028
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
10 // <chrono>
12 // round
14 // template <class ToDuration, class Rep, class Period>
15 // constexpr
16 // ToDuration
17 // ceil(const duration<Rep, Period>& d);
19 #include <chrono>
20 #include <type_traits>
21 #include <cassert>
23 #include "test_macros.h"
25 template <class ToDuration, class FromDuration>
26 void
27 test(const FromDuration& f, const ToDuration& d)
30 typedef decltype(std::chrono::round<ToDuration>(f)) R;
31 static_assert((std::is_same<R, ToDuration>::value), "");
32 assert(std::chrono::round<ToDuration>(f) == d);
36 int main(int, char**)
38 // 7290000ms is 2 hours, 1 minute, and 30 seconds
39 test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2));
40 test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2));
41 test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122));
42 test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122));
45 // 9000000ms is 2 hours and 30 minutes
46 constexpr std::chrono::hours h1 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(9000000));
47 static_assert(h1.count() == 2, "");
48 constexpr std::chrono::hours h2 = std::chrono::round<std::chrono::hours>(std::chrono::milliseconds(-9000000));
49 static_assert(h2.count() == -2, "");
52 return 0;