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>
10
11 // constexpr bool is_am(const hours& h) noexcept;
12 // Returns: 0h <= h && h <= 11h.
13
14 #include <chrono>
15 #include <cassert>
16 #include <utility>
17
18 #include "test_macros.h"
19
main(int,char **)20 int main(int, char**)
21 {
22 using hours = std::chrono::hours;
23 ASSERT_SAME_TYPE(bool, decltype(std::chrono::is_am(std::declval<hours>())));
24 ASSERT_NOEXCEPT( std::chrono::is_am(std::declval<hours>()));
25
26 static_assert( std::chrono::is_am(hours( 0)), "");
27 static_assert( std::chrono::is_am(hours(11)), "");
28 static_assert(!std::chrono::is_am(hours(12)), "");
29 static_assert(!std::chrono::is_am(hours(23)), "");
30
31 for (int i = 0; i < 12; ++i)
32 assert( std::chrono::is_am(hours(i)));
33 for (int i = 12; i < 24; ++i)
34 assert(!std::chrono::is_am(hours(i)));
35
36 return 0;
37 }
38