assign.pass.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // XFAIL: libcpp-no-exceptions
  10. // <regex>
  11. // template <class charT, class traits = regex_traits<charT>> class basic_regex;
  12. // basic_regex& assign(const basic_regex& that);
  13. #include <regex>
  14. #include <cassert>
  15. int main()
  16. {
  17. std::regex r1("(a([bc]))");
  18. std::regex r2;
  19. r2.assign(r1);
  20. assert(r2.flags() == std::regex::ECMAScript);
  21. assert(r2.mark_count() == 2);
  22. assert(std::regex_search("ab", r2));
  23. bool caught = false;
  24. try { r2.assign("(def", std::regex::extended); }
  25. catch(std::regex_error &) { caught = true; }
  26. assert(caught);
  27. assert(r2.flags() == std::regex::ECMAScript);
  28. assert(r2.mark_count() == 2);
  29. assert(std::regex_search("ab", r2));
  30. }