From bc2c6b80dcaf6b10466cfb6f61fa32bcf70680ad Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 29 Aug 2021 23:37:09 +0700 Subject: [PATCH] address review comments Co-authored-by: Alex Guteniev --- .../tests/GH_002168_regex_overflow/test.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/std/tests/GH_002168_regex_overflow/test.cpp b/tests/std/tests/GH_002168_regex_overflow/test.cpp index efcfd543b1..b5271be56c 100644 --- a/tests/std/tests/GH_002168_regex_overflow/test.cpp +++ b/tests/std/tests/GH_002168_regex_overflow/test.cpp @@ -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); + } + } }