blob: eba76c808b3017dd411af358b29ce33e83197a8d [file] [log] [blame]
Marshall Clow5a726792017-09-12 17:56:59 +00001//===----------------------------------------------------------------------===//
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
10// <regex>
Marshall Clowc589f5f2017-09-12 19:01:32 +000011// XFAIL: c++03
Marshall Clow5a726792017-09-12 17:56:59 +000012
13// template <class BidirectionalIterator, class Allocator, class charT, class traits>
14// bool
15// regex_search(BidirectionalIterator first, BidirectionalIterator last,
16// match_results<BidirectionalIterator, Allocator>& m,
17// const basic_regex<charT, traits>& e,
18// regex_constants::match_flag_type flags = regex_constants::match_default);
19
20// Throw exception after spent too many cycles with respect to the length of the input string.
21
22#include <regex>
23#include <cassert>
24
25int main() {
26 for (std::regex_constants::syntax_option_type op :
27 {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
28 std::regex::awk}) {
29 try {
30 std::regex_search(
31 "aaaaaaaaaaaaaaaaaaaa",
32 std::regex(
33 "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa",
34 op));
35 assert(false);
36 } catch (const std::regex_error &e) {
37 assert(e.code() == std::regex_constants::error_complexity);
38 }
39 }
40 std::string s(100000, 'a');
41 for (std::regex_constants::syntax_option_type op :
42 {std::regex::ECMAScript, std::regex::extended, std::regex::egrep,
43 std::regex::awk}) {
44 assert(std::regex_search(s, std::regex("a*", op)));
45 }
46 return 0;
47}