exponential.pass.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. // <regex>
  9. // UNSUPPORTED: libcpp-no-exceptions
  10. // template <class OutputIterator, class BidirectionalIterator,
  11. // class traits, class charT, class ST, class SA>
  12. // OutputIterator
  13. // regex_replace(OutputIterator out,
  14. // BidirectionalIterator first, BidirectionalIterator last,
  15. // const basic_regex<charT, traits>& e,
  16. // const basic_string<charT, ST, SA>& fmt,
  17. // regex_constants::match_flag_type flags =
  18. // regex_constants::match_default);
  19. #include <regex>
  20. #include <cassert>
  21. #include "test_macros.h"
  22. int main(int, char**)
  23. {
  24. try {
  25. std::regex re("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa");
  26. const char s[] = "aaaaaaaaaaaaaaaaaaaa";
  27. std::string r = std::regex_replace(s, re, "123-&", std::regex_constants::format_sed);
  28. LIBCPP_ASSERT(false);
  29. assert(r == "123-aaaaaaaaaaaaaaaaaaaa");
  30. } catch (const std::regex_error &e) {
  31. assert(e.code() == std::regex_constants::error_complexity);
  32. }
  33. return 0;
  34. }