• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 // <chrono>
10 
11 // duration
12 
13 // static constexpr duration max(); // noexcept after C++17
14 
15 #include <chrono>
16 #include <limits>
17 #include <cassert>
18 
19 #include "test_macros.h"
20 #include "../../rep.h"
21 
22 template <class D>
test()23 void test()
24 {
25     LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::max());
26 #if TEST_STD_VER > 17
27     ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::max());
28 #endif
29     {
30     typedef typename D::rep DRep;
31     DRep max_rep = std::chrono::duration_values<DRep>::max();
32     assert(D::max().count() == max_rep);
33     }
34 #if TEST_STD_VER >= 11
35     {
36     typedef typename D::rep DRep;
37     constexpr DRep max_rep = std::chrono::duration_values<DRep>::max();
38     static_assert(D::max().count() == max_rep, "");
39     }
40 #endif
41 }
42 
main(int,char **)43 int main(int, char**)
44 {
45     test<std::chrono::duration<int> >();
46     test<std::chrono::duration<Rep> >();
47 
48   return 0;
49 }
50