From 8e50da6875aee90b53de596fc01ba1cc5ca50f73 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 31 Jul 2022 22:21:56 +0200 Subject: [PATCH] Don't mix flags from different enums in wxRegEx unit test Pass compilation and matching flags using separate parameters instead of passing them as a single int and then separating them inside the function. This is a bit cleaner and also avoids warning about using deprecated enum operations when using C++20. (cherry picked from commit 4b0fa10a290d899278007f4743df3f811df506a1) --- tests/regex/wxregextest.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/regex/wxregextest.cpp b/tests/regex/wxregextest.cpp index e1d58d1f65..291ed7afb1 100644 --- a/tests/regex/wxregextest.cpp +++ b/tests/regex/wxregextest.cpp @@ -71,12 +71,12 @@ static void CheckMatch(const char* pattern, const char* text, const char* expected = NULL, - int flags = wxRE_DEFAULT) + int compileFlags = wxRE_DEFAULT, + int matchFlags = 0) { - int compileFlags = flags & ~(wxRE_NOTBOL | wxRE_NOTEOL); - int matchFlags = flags & (wxRE_NOTBOL | wxRE_NOTEOL); - - INFO( "Pattern: " << pattern << FlagStr(flags) << ", match: " << text ); + INFO( "Pattern: " + << pattern << FlagStr(static_cast(compileFlags) | matchFlags) + << ", match: " << text ); wxRegEx re(pattern, compileFlags); if ( !re.IsValid() ) @@ -104,7 +104,7 @@ CheckMatch(const char* pattern, CHECK( re.GetMatch(text, i) == tkz.GetNextToken() ); } - if ((flags & wxRE_NOSUB) == 0) + if ((compileFlags & wxRE_NOSUB) == 0) CHECK(re.GetMatchCount() == i); } @@ -124,8 +124,8 @@ TEST_CASE("wxRegEx::Match", "[regex][match]") CheckMatch("^[A-Z].*$", "AA\nbb\nCC", "AA\nbb\nCC"); CheckMatch("^[A-Z].*$", "AA\nbb\nCC", "AA", wxRE_NEWLINE); CheckMatch("^[a-z].*$", "AA\nbb\nCC", "bb", wxRE_NEWLINE); - CheckMatch("^[A-Z].*$", "AA\nbb\nCC", "CC", wxRE_NEWLINE | wxRE_NOTBOL); - CheckMatch("^[A-Z].*$", "AA\nbb\nCC", NULL, wxRE_NEWLINE | wxRE_NOTBOL | wxRE_NOTEOL); + CheckMatch("^[A-Z].*$", "AA\nbb\nCC", "CC", wxRE_NEWLINE, wxRE_NOTBOL); + CheckMatch("^[A-Z].*$", "AA\nbb\nCC", NULL, wxRE_NEWLINE, wxRE_NOTBOL | wxRE_NOTEOL); CheckMatch("([[:alpha:]]+) ([[:alpha:]]+) ([[:digit:]]+).* ([[:digit:]]+)$", "Fri Jul 13 18:37:52 CEST 2001", "Fri Jul 13 18:37:52 CEST 2001\tFri\tJul\t13\t2001");