Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Guteniev <gutenev@gmail.com>
  • Loading branch information
fsb4000 and AlexGuteniev committed Aug 29, 2021
1 parent b61e657 commit bc2c6b8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tests/std/tests/GH_002168_regex_overflow/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

using namespace std;

bool shouldThrow(const char* const regexString) {
try {
regex regex{regexString, regex_constants::ECMAScript};
return false;
} catch (const regex_error& e) {
return e.code() == regex_constants::error_backref;
}
}

int main() {
assert(shouldThrow("\\3333333334"));
assert(shouldThrow("\\2147483648"));
for (const char* regexString : {"\\3333333334", "\\2147483648"}) {
try {
regex testRegex{regexString, regex_constants::ECMAScript};
assert(false);
} catch (const regex_error& e) {
assert(e.code() == regex_constants::error_backref);
}
}
}

0 comments on commit bc2c6b8

Please sign in to comment.