blob: 316759fd895dd9e1c0df27daef37d5b50067318e [file] [log] [blame]
Marshall Clowdd426c22019-01-31 18:54:26 +00001//===----------------------------------------------------------------------===//
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
9// <regex>
Louis Dionne8c611142020-04-17 10:29:15 -040010// UNSUPPORTED: no-exceptions
Marshall Clowdd426c22019-01-31 18:54:26 +000011
12// template <class OutputIterator, class BidirectionalIterator,
13// class traits, class charT, class ST, class SA>
14// OutputIterator
15// regex_replace(OutputIterator out,
16// BidirectionalIterator first, BidirectionalIterator last,
17// const basic_regex<charT, traits>& e,
18// const basic_string<charT, ST, SA>& fmt,
19// regex_constants::match_flag_type flags =
20// regex_constants::match_default);
21
22#include <regex>
23#include <cassert>
24
25#include "test_macros.h"
26
JF Bastien2df59c52019-02-04 20:31:13 +000027int main(int, char**)
Marshall Clowdd426c22019-01-31 18:54:26 +000028{
29 try {
30 std::regex re("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa");
31 const char s[] = "aaaaaaaaaaaaaaaaaaaa";
32 std::string r = std::regex_replace(s, re, "123-&", std::regex_constants::format_sed);
33 LIBCPP_ASSERT(false);
34 assert(r == "123-aaaaaaaaaaaaaaaaaaaa");
35 } catch (const std::regex_error &e) {
36 assert(e.code() == std::regex_constants::error_complexity);
37 }
JF Bastien2df59c52019-02-04 20:31:13 +000038 return 0;
Marshall Clowdd426c22019-01-31 18:54:26 +000039}