• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <chrono>
11 
12 // duration
13 
14 // static constexpr duration max(); // noexcept after C++17
15 
16 #include <chrono>
17 #include <limits>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 #include "../../rep.h"
22 
23 template <class D>
test()24 void test()
25 {
26     LIBCPP_ASSERT_NOEXCEPT(std::chrono::duration_values<typename D::rep>::max());
27 #if TEST_STD_VER > 17
28     ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::max());
29 #endif
30     {
31     typedef typename D::rep Rep;
32     Rep max_rep = std::chrono::duration_values<Rep>::max();
33     assert(D::max().count() == max_rep);
34     }
35 #if TEST_STD_VER >= 11
36     {
37     typedef typename D::rep Rep;
38     constexpr Rep max_rep = std::chrono::duration_values<Rep>::max();
39     static_assert(D::max().count() == max_rep, "");
40     }
41 #endif
42 }
43 
main()44 int main()
45 {
46     test<std::chrono::duration<int> >();
47     test<std::chrono::duration<Rep> >();
48 }
49