max.pass.cpp 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // <chrono>
  10. // duration
  11. // static constexpr duration max();
  12. #include <chrono>
  13. #include <limits>
  14. #include <cassert>
  15. #include "test_macros.h"
  16. #include "../../rep.h"
  17. template <class D>
  18. void test()
  19. {
  20. {
  21. typedef typename D::rep Rep;
  22. Rep max_rep = std::chrono::duration_values<Rep>::max();
  23. assert(D::max().count() == max_rep);
  24. }
  25. #if TEST_STD_VER >= 11
  26. {
  27. typedef typename D::rep Rep;
  28. constexpr Rep max_rep = std::chrono::duration_values<Rep>::max();
  29. static_assert(D::max().count() == max_rep, "");
  30. }
  31. #endif
  32. }
  33. int main()
  34. {
  35. test<std::chrono::duration<int> >();
  36. test<std::chrono::duration<Rep> >();
  37. }