1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
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.
19 #include "test_macros.h"
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));