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
4adbc9c9
Commit
4adbc9c9
authored
Dec 17, 2021
by
Hossein Ghahramanzadeh
Browse files
Apply requested changes to preserve old behavior.
parent
d03d23a6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
googletest/src/gtest.cc
googletest/src/gtest.cc
+20
-13
No files found.
googletest/src/gtest.cc
View file @
4adbc9c9
...
...
@@ -50,6 +50,7 @@
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream> // NOLINT
#include <sstream>
#include <vector>
...
...
@@ -724,26 +725,26 @@ static bool PatternMatchesString(const std::string& name_str,
}
namespace
{
class
UnitTestFilter
{
public:
UnitTestFilter
()
=
default
;
// Constructs a filter form a string of patterns separated by `:`.
explicit
UnitTestFilter
(
const
std
::
string
&
filter
)
{
if
(
filter
.
empty
())
return
;
// By design "" filter matches "" string.
SplitString
(
filter
,
':'
,
&
patterns_
);
}
// Returns true if and only if name matches at least one of the patterns in
// the filter.
bool
MatchesName
(
const
std
::
string
&
name
)
const
{
const
auto
pattern_matches_name
=
[
&
name
](
const
std
::
string
&
pattern
)
{
return
PatternMatchesString
(
name
,
pattern
.
c_str
(),
pattern
.
c_str
()
+
pattern
.
size
());
};
return
std
::
any_of
(
patterns_
.
begin
(),
patterns_
.
end
(),
pattern_matches_name
);
[
&
name
](
const
std
::
string
&
pattern
)
{
return
PatternMatchesString
(
name
,
pattern
.
c_str
(),
pattern
.
c_str
()
+
pattern
.
size
());
});
}
private:
...
...
@@ -766,10 +767,18 @@ class PositiveAndNegativeUnitTestFilter {
if
(
positive_and_negative_filters
.
size
()
>
1
)
{
positive_filter_
=
UnitTestFilter
{
positive_filter
.
size
()
?
positive_filter
:
kUniversalFilter
};
negative_filter_
=
UnitTestFilter
{
positive_and_negative_filters
.
back
()};
// TODO: Fail on multiple '-' characters
// For the moment to preserve old behavior we concatenate the rest of the
// string parts with `-` as separator to generate the negative filter.
negative_filter_
=
UnitTestFilter
{
std
::
accumulate
(
positive_and_negative_filters
.
begin
()
+
2
,
positive_and_negative_filters
.
end
(),
positive_and_negative_filters
[
1
],
[](
const
auto
&
lhs
,
const
auto
&
rhs
)
{
return
lhs
+
'-'
+
rhs
;
})};
}
else
{
// In case positive filter is empty
// we do not use kUniversalFilter by design
// In case we don't have a negative filter and positive filter is ""
// we do not use kUniversalFilter by design as opposed to when we have a
// negative filter.
positive_filter_
=
UnitTestFilter
{
positive_filter
};
}
}
...
...
@@ -779,9 +788,7 @@ class PositiveAndNegativeUnitTestFilter {
// and does not match the negative filter.
bool
MatchesTest
(
const
std
::
string
&
test_suite_name
,
const
std
::
string
&
test_name
)
const
{
const
std
::
string
&
full_name
=
test_suite_name
+
"."
+
test_name
.
c_str
();
return
MatchesName
(
full_name
);
return
MatchesName
(
test_suite_name
+
"."
+
test_name
);
}
// Returns true if and only if name matches the positive filter and does not
...
...
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