Changeset View
Changeset View
Standalone View
Standalone View
test/std/re/re.alg/re.alg.search/exponential.pass.cpp
Show All 15 Lines | |||||
// match_results<BidirectionalIterator, Allocator>& m, | // match_results<BidirectionalIterator, Allocator>& m, | ||||
// const basic_regex<charT, traits>& e, | // const basic_regex<charT, traits>& e, | ||||
// regex_constants::match_flag_type flags = regex_constants::match_default); | // regex_constants::match_flag_type flags = regex_constants::match_default); | ||||
// Throw exception after spent too many cycles with respect to the length of the input string. | // Throw exception after spent too many cycles with respect to the length of the input string. | ||||
#include <regex> | #include <regex> | ||||
#include <cassert> | #include <cassert> | ||||
#include "test_macros.h" | |||||
int main() { | int main() { | ||||
for (std::regex_constants::syntax_option_type op : | for (std::regex_constants::syntax_option_type op : | ||||
{std::regex::ECMAScript, std::regex::extended, std::regex::egrep, | {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, | ||||
std::regex::awk}) { | std::regex::awk}) { | ||||
try { | try { | ||||
std::regex_search( | bool b = std::regex_search( | ||||
"aaaaaaaaaaaaaaaaaaaa", | "aaaaaaaaaaaaaaaaaaaa", | ||||
std::regex( | std::regex( | ||||
"a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa", | "a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaa", | ||||
op)); | op)); | ||||
assert(false); | LIBCPP_ASSERT(false); | ||||
assert(b); | |||||
} catch (const std::regex_error &e) { | } catch (const std::regex_error &e) { | ||||
assert(e.code() == std::regex_constants::error_complexity); | assert(e.code() == std::regex_constants::error_complexity); | ||||
} | } | ||||
} | } | ||||
std::string s(100000, 'a'); | std::string s(100000, 'a'); | ||||
for (std::regex_constants::syntax_option_type op : | for (std::regex_constants::syntax_option_type op : | ||||
{std::regex::ECMAScript, std::regex::extended, std::regex::egrep, | {std::regex::ECMAScript, std::regex::extended, std::regex::egrep, | ||||
std::regex::awk}) { | std::regex::awk}) { | ||||
assert(std::regex_search(s, std::regex("a*", op))); | assert(std::regex_search(s, std::regex("a*", op))); | ||||
} | } | ||||
return 0; | return 0; | ||||
} | } |