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
f5b4efef
Commit
f5b4efef
authored
Oct 17, 2021
by
Hossein Ghahramanzadeh
Browse files
Add comments describing the behavior of filters
parent
2377c8d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
googletest/src/gtest.cc
googletest/src/gtest.cc
+13
-1
No files found.
googletest/src/gtest.cc
View file @
f5b4efef
...
@@ -752,6 +752,7 @@ class Filter {
...
@@ -752,6 +752,7 @@ class Filter {
std
::
vector
<
std
::
string
>
patterns_
;
std
::
vector
<
std
::
string
>
patterns_
;
public:
public:
// Constructs a filter form a string of patterns separated by `:`.
explicit
Filter
(
const
std
::
string
&
filter
)
{
explicit
Filter
(
const
std
::
string
&
filter
)
{
if
(
filter
.
empty
())
return
;
if
(
filter
.
empty
())
return
;
...
@@ -766,6 +767,8 @@ class Filter {
...
@@ -766,6 +767,8 @@ class Filter {
}
}
}
}
// Returns true if and only if name matches at least one of the patterns in
// the filter.
bool
MatchesName
(
const
std
::
string
&
name
)
const
{
bool
MatchesName
(
const
std
::
string
&
name
)
const
{
const
auto
pattern_matches_name
=
[
&
name
](
const
std
::
string
&
pattern
)
{
const
auto
pattern_matches_name
=
[
&
name
](
const
std
::
string
&
pattern
)
{
return
PatternMatchesString
(
name
,
pattern
.
c_str
(),
return
PatternMatchesString
(
name
,
pattern
.
c_str
(),
...
@@ -790,17 +793,24 @@ class PositiveAndNegativeFilter {
...
@@ -790,17 +793,24 @@ class PositiveAndNegativeFilter {
filter
.
substr
(
dash_pos
+
1
)};
filter
.
substr
(
dash_pos
+
1
)};
}
}
}
}
PositiveAndNegativeFilter
(
PositiveAndNegativeFilter
(
const
std
::
pair
<
std
::
string
,
std
::
string
>&
positive_and_negative_filters
)
const
std
::
pair
<
std
::
string
,
std
::
string
>&
positive_and_negative_filters
)
:
positive_filter_
(
positive_and_negative_filters
.
first
),
:
positive_filter_
(
positive_and_negative_filters
.
first
),
negative_filter_
(
positive_and_negative_filters
.
second
)
{}
negative_filter_
(
positive_and_negative_filters
.
second
)
{}
public:
public:
// Constructs a positive and a negative filter from a string. The string
// contains a positive filter optionally followed by a '-' character and a
// negative filter. In case only a negative filter is provided the positive
// filter will be assumed "*".
// A filter is a list of patterns separated by ':'.
explicit
PositiveAndNegativeFilter
(
const
std
::
string
&
filter
)
explicit
PositiveAndNegativeFilter
(
const
std
::
string
&
filter
)
:
PositiveAndNegativeFilter
(
BreakIntoPositiveAndNegativeFilters
(
filter
))
{
:
PositiveAndNegativeFilter
(
BreakIntoPositiveAndNegativeFilters
(
filter
))
{
}
}
// Returns true if and only if test name (this is generated by appending test
// suit name and test name via a '.' character) matches the positive filter
// and does not match the negative filter.
bool
MatchesTest
(
const
std
::
string
&
test_suite_name
,
bool
MatchesTest
(
const
std
::
string
&
test_suite_name
,
const
std
::
string
&
test_name
)
const
{
const
std
::
string
&
test_name
)
const
{
const
std
::
string
&
full_name
=
test_suite_name
+
"."
+
test_name
.
c_str
();
const
std
::
string
&
full_name
=
test_suite_name
+
"."
+
test_name
.
c_str
();
...
@@ -808,6 +818,8 @@ class PositiveAndNegativeFilter {
...
@@ -808,6 +818,8 @@ class PositiveAndNegativeFilter {
return
MatchesName
(
full_name
);
return
MatchesName
(
full_name
);
}
}
// Returns true if and only if name matches the positive filter and does not
// match the negative filter.
bool
MatchesName
(
const
std
::
string
&
name
)
const
{
bool
MatchesName
(
const
std
::
string
&
name
)
const
{
return
positive_filter_
.
MatchesName
(
name
)
&&
return
positive_filter_
.
MatchesName
(
name
)
&&
!
negative_filter_
.
MatchesName
(
name
);
!
negative_filter_
.
MatchesName
(
name
);
...
...
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