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 // template <class Duration>
14 // constexpr bool is_negative() const noexcept;
21 #include "test_macros.h"
23 template <typename Duration
>
24 constexpr bool check_neg(Duration d
)
26 ASSERT_SAME_TYPE(bool, decltype(std::declval
<std::chrono::hh_mm_ss
<Duration
>>().is_negative()));
27 ASSERT_NOEXCEPT( std::declval
<std::chrono::hh_mm_ss
<Duration
>>().is_negative());
28 return std::chrono::hh_mm_ss
<Duration
>(d
).is_negative();
33 using microfortnights
= std::chrono::duration
<int, std::ratio
<756, 625>>;
35 static_assert(!check_neg(std::chrono::minutes( 1)), "");
36 static_assert( check_neg(std::chrono::minutes(-1)), "");
38 assert(!check_neg(std::chrono::seconds( 5000)));
39 assert( check_neg(std::chrono::seconds(-5000)));
40 assert(!check_neg(std::chrono::minutes( 5000)));
41 assert( check_neg(std::chrono::minutes(-5000)));
42 assert(!check_neg(std::chrono::hours( 11)));
43 assert( check_neg(std::chrono::hours(-11)));
45 assert(!check_neg(std::chrono::milliseconds( 123456789LL)));
46 assert( check_neg(std::chrono::milliseconds(-123456789LL)));
47 assert(!check_neg(std::chrono::microseconds( 123456789LL)));
48 assert( check_neg(std::chrono::microseconds(-123456789LL)));
49 assert(!check_neg(std::chrono::nanoseconds( 123456789LL)));
50 assert( check_neg(std::chrono::nanoseconds(-123456789LL)));
52 assert(!check_neg(microfortnights( 10000)));
53 assert( check_neg(microfortnights(-10000)));