op_-=.pass.cpp 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // <chrono>
  9. // duration
  10. // duration& operator-=(const duration& d);
  11. #include <chrono>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. #if TEST_STD_VER > 14
  15. constexpr bool test_constexpr()
  16. {
  17. std::chrono::seconds s(3);
  18. s -= std::chrono::seconds(2);
  19. if (s.count() != 1) return false;
  20. s -= std::chrono::minutes(2);
  21. return s.count() == -119;
  22. }
  23. #endif
  24. int main(int, char**)
  25. {
  26. {
  27. std::chrono::seconds s(3);
  28. s -= std::chrono::seconds(2);
  29. assert(s.count() == 1);
  30. s -= std::chrono::minutes(2);
  31. assert(s.count() == -119);
  32. }
  33. #if TEST_STD_VER > 14
  34. static_assert(test_constexpr(), "");
  35. #endif
  36. return 0;
  37. }