Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f2068873
Commit
f2068873
authored
Oct 17, 2021
by
Hossein Ghahramanzadeh
Browse files
Get rid of redundant filter matching code
parent
f5b4efef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
52 deletions
+1
-52
googletest/src/gtest-internal-inl.h
googletest/src/gtest-internal-inl.h
+0
-4
googletest/src/gtest.cc
googletest/src/gtest.cc
+1
-48
No files found.
googletest/src/gtest-internal-inl.h
View file @
f2068873
...
...
@@ -390,10 +390,6 @@ class GTEST_API_ UnitTestOptions {
// This function is useful as an __except condition.
static
int
GTestShouldProcessSEH
(
DWORD
exception_code
);
#endif // GTEST_OS_WINDOWS
// Returns true if "name" matches the ':' separated list of glob-style
// filters in "filter".
static
bool
MatchesFilter
(
const
std
::
string
&
name
,
const
char
*
filter
);
};
// Returns the current application's name, removing directory path if that
...
...
googletest/src/gtest.cc
View file @
f2068873
...
...
@@ -723,31 +723,6 @@ static bool PatternMatchesString(const std::string& name_str,
return
true
;
}
bool
UnitTestOptions
::
MatchesFilter
(
const
std
::
string
&
name_str
,
const
char
*
filter
)
{
// The filter is a list of patterns separated by colons (:).
const
char
*
pattern
=
filter
;
while
(
true
)
{
// Find the bounds of this pattern.
const
char
*
const
next_sep
=
strchr
(
pattern
,
':'
);
const
char
*
const
pattern_end
=
next_sep
!=
nullptr
?
next_sep
:
pattern
+
strlen
(
pattern
);
// Check if this pattern matches name_str.
if
(
PatternMatchesString
(
name_str
,
pattern
,
pattern_end
))
{
return
true
;
}
// Give up on this pattern. However, if we found a pattern separator (:),
// advance to the next pattern (skipping over the separator) and restart.
if
(
next_sep
==
nullptr
)
{
return
false
;
}
pattern
=
next_sep
+
1
;
}
return
true
;
}
class
Filter
{
std
::
vector
<
std
::
string
>
patterns_
;
...
...
@@ -830,31 +805,9 @@ class PositiveAndNegativeFilter {
// suite name and the test name.
bool
UnitTestOptions
::
FilterMatchesTest
(
const
std
::
string
&
test_suite_name
,
const
std
::
string
&
test_name
)
{
const
std
::
string
&
full_name
=
test_suite_name
+
"."
+
test_name
.
c_str
();
// Split --gtest_filter at '-', if there is one, to separate into
// positive filter and negative filter portions
std
::
string
str
=
GTEST_FLAG_GET
(
filter
);
const
char
*
const
p
=
str
.
c_str
();
const
char
*
const
dash
=
strchr
(
p
,
'-'
);
std
::
string
positive
;
std
::
string
negative
;
if
(
dash
==
nullptr
)
{
positive
=
str
.
c_str
();
// Whole string is a positive filter
negative
=
""
;
}
else
{
positive
=
std
::
string
(
p
,
dash
);
// Everything up to the dash
negative
=
std
::
string
(
dash
+
1
);
// Everything after the dash
if
(
positive
.
empty
())
{
// Treat '-test1' as the same as '*-test1'
positive
=
kUniversalFilter
;
}
}
// A filter is a colon-separated list of patterns. It matches a
// test if any pattern in it matches the test.
return
(
MatchesFilter
(
full_name
,
positive
.
c_str
())
&&
!
MatchesFilter
(
full_name
,
negative
.
c_str
()));
return
PositiveAndNegativeFilter
{
GTEST_FLAG_GET
(
filter
)}.
MatchesTest
(
test_suite_name
,
test_name
);
}
#if GTEST_HAS_SEH
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment