[Object][WebAssembly] Fix data segment offsets higher than 2^31 (#125739)
[llvm-project.git] / libcxx / test / std / time / time.hms / time.12 / make12.pass.cpp
blobe0000968abd4b673384c4cd3210fddbfb50cb4b9
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 // constexpr hours make12(const hours& h) noexcept;
12 // Returns: The 12-hour equivalent of h in the range [1h, 12h].
13 // If h is not in the range [0h, 23h], the value returned is unspecified.
15 #include <chrono>
16 #include <cassert>
17 #include <utility>
19 #include "test_macros.h"
21 int main(int, char**)
23 using hours = std::chrono::hours;
24 ASSERT_SAME_TYPE(hours, decltype(std::chrono::make12(std::declval<hours>())));
25 ASSERT_NOEXCEPT( std::chrono::make12(std::declval<hours>()));
27 static_assert( std::chrono::make12(hours( 0)) == hours(12), "");
28 static_assert( std::chrono::make12(hours(11)) == hours(11), "");
29 static_assert( std::chrono::make12(hours(12)) == hours(12), "");
30 static_assert( std::chrono::make12(hours(23)) == hours(11), "");
32 assert( std::chrono::make12(hours(0)) == hours(12));
33 for (int i = 1; i < 13; ++i)
34 assert( std::chrono::make12(hours(i)) == hours(i));
35 for (int i = 13; i < 24; ++i)
36 assert( std::chrono::make12(hours(i)) == hours(i-12));
38 return 0;