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.
This commit is contained in:
Vadim Zeitlin 2021-06-19 14:29:31 +02:00
parent 862c051e9e
commit 381cd322ec

View File

@ -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);