xref: /llvm-project/libcxx/test/std/time/time.duration/time.duration.special/min.pass.cpp (revision 7738db2c06b177fe916ac1bcf3633449b3c1fca9)
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 min(); // 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>::min());
26 #if TEST_STD_VER > 17
27     ASSERT_NOEXCEPT(       std::chrono::duration_values<typename D::rep>::min());
28 #endif
29     {
30     typedef typename D::rep DRep;
31     DRep min_rep = std::chrono::duration_values<DRep>::min();
32     assert(D::min().count() == min_rep);
33     }
34 #if TEST_STD_VER >= 11
35     {
36     typedef typename D::rep DRep;
37     constexpr DRep min_rep = std::chrono::duration_values<DRep>::min();
38     static_assert(D::min().count() == min_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