From 381cd322ec3e351ecfd75e8112f6d0a2a8bec1d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 19 Jun 2021 14:29:31 +0200 Subject: [PATCH] Always skip the rest of regex tests checking for compile failure It's useless to continue with testing the given regex if compiling it has unexpectedly succeeded, all the rest of the tests will fail anyhow. Also explain that REQUIRE() can't be used here, which is why we need to use CHECK() and then check the same condition again before returning to avoid the temptation to "simplify" things. --- tests/regex/regextest.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/regex/regextest.cpp b/tests/regex/regextest.cpp index 321fd29c85..4902c852d1 100644 --- a/tests/regex/regextest.cpp +++ b/tests/regex/regextest.cpp @@ -234,12 +234,18 @@ void RegExTestCase::doTest(int flavor) // 'e' - test that the pattern fails to compile if (m_mode == 'e') { CHECK( !re.IsValid() ); - } else { - CHECK( re.IsValid() ); - } - if (!re.IsValid()) + // Never continue with this kind of test. return; + } else { + // Note: we don't use REQUIRE here because this would abort the entire + // test case on error instead of skipping just the rest of this regex + // test. + CHECK( re.IsValid() ); + + if (!re.IsValid()) + return; + } bool matches = re.Matches(m_data, m_matchFlags);