assign.pass.cpp 926 B

123456789101112131415161718192021222324252627282930313233343536
  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. // <system_error>
  9. // class error_code
  10. // void assign(int val, const error_category& cat);
  11. #include <system_error>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. int main(int, char**)
  15. {
  16. {
  17. std::error_code ec;
  18. ec.assign(6, std::system_category());
  19. assert(ec.value() == 6);
  20. assert(ec.category() == std::system_category());
  21. }
  22. {
  23. std::error_code ec;
  24. ec.assign(8, std::generic_category());
  25. assert(ec.value() == 8);
  26. assert(ec.category() == std::generic_category());
  27. }
  28. return 0;
  29. }