Use CHECK rather than REQUIRE in individual regex tests

Don't prevent the remaining CheckMatch() tests from running if one of
them fails by using CHECK() rather than REQUIRE().

This is a bit awkward and we probably ought to use sections here
instead, but this change is more minimal.

This commit is best viewed ignoring whitespace-only changes.
This commit is contained in:
Vadim Zeitlin
2021-06-20 16:19:38 +02:00
parent 381cd322ec
commit 8be998861d

View File

@@ -79,28 +79,33 @@ CheckMatch(const char* pattern,
INFO( "Pattern: " << pattern << FlagStr(flags) << ", match: " << text ); INFO( "Pattern: " << pattern << FlagStr(flags) << ", match: " << text );
wxRegEx re(pattern, compileFlags); wxRegEx re(pattern, compileFlags);
REQUIRE( re.IsValid() ); if ( !re.IsValid() )
{
bool ok = re.Matches(text, matchFlags); FAIL("Regex compilation failed");
return;
if (expected) {
REQUIRE( ok );
wxStringTokenizer tkz(wxString(expected, *wxConvCurrent),
wxT("\t"), wxTOKEN_RET_EMPTY);
size_t i;
for (i = 0; i < re.GetMatchCount() && tkz.HasMoreTokens(); i++) {
INFO( "Match #" << i );
CHECK( re.GetMatch(text, i) == tkz.GetNextToken() );
}
if ((flags & wxRE_NOSUB) == 0)
CHECK(re.GetMatchCount() == i);
} }
else {
CHECK( !ok ); if ( !re.Matches(text, matchFlags) )
{
CHECK( !expected );
return;
} }
CHECK( expected );
if ( !expected )
return;
wxStringTokenizer tkz(wxString(expected, *wxConvCurrent),
wxT("\t"), wxTOKEN_RET_EMPTY);
size_t i;
for (i = 0; i < re.GetMatchCount() && tkz.HasMoreTokens(); i++) {
INFO( "Match #" << i );
CHECK( re.GetMatch(text, i) == tkz.GetNextToken() );
}
if ((flags & wxRE_NOSUB) == 0)
CHECK(re.GetMatchCount() == i);
} }
TEST_CASE("wxRegEx::Match", "[regex][match]") TEST_CASE("wxRegEx::Match", "[regex][match]")