Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
d6841c04
Commit
d6841c04
authored
Feb 05, 2022
by
Hossein Ghahramanzadeh
Browse files
Apply requested changes by using std::inserter with move.
parent
2eadda6e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
googletest/src/gtest.cc
googletest/src/gtest.cc
+11
-9
No files found.
googletest/src/gtest.cc
View file @
d6841c04
...
@@ -726,13 +726,13 @@ static bool PatternMatchesString(const std::string& name_str,
...
@@ -726,13 +726,13 @@ static bool PatternMatchesString(const std::string& name_str,
return
true
;
return
true
;
}
}
static
bool
IsGlobPattern
(
const
std
::
string
&
pattern
)
{
namespace
{
bool
IsGlobPattern
(
const
std
::
string
&
pattern
)
{
return
std
::
any_of
(
pattern
.
begin
(),
pattern
.
end
(),
return
std
::
any_of
(
pattern
.
begin
(),
pattern
.
end
(),
[](
const
char
c
)
{
return
c
==
'?'
||
c
==
'*'
;
});
[](
const
char
c
)
{
return
c
==
'?'
||
c
==
'*'
;
});
}
}
namespace
{
class
UnitTestFilter
{
class
UnitTestFilter
{
public:
public:
UnitTestFilter
()
=
default
;
UnitTestFilter
()
=
default
;
...
@@ -740,12 +740,14 @@ class UnitTestFilter {
...
@@ -740,12 +740,14 @@ class UnitTestFilter {
// Constructs a filter from a string of patterns separated by `:`.
// Constructs a filter from a string of patterns separated by `:`.
explicit
UnitTestFilter
(
const
std
::
string
&
filter
)
{
explicit
UnitTestFilter
(
const
std
::
string
&
filter
)
{
// By design "" filter matches "" string.
// By design "" filter matches "" string.
SplitString
(
filter
,
':'
,
&
glob_patterns_
);
std
::
vector
<
std
::
string
>
all_patterns
;
const
auto
exact_match_pattern_begin
=
std
::
partition
(
SplitString
(
filter
,
':'
,
&
all_patterns
);
glob_patterns_
.
begin
(),
glob_patterns_
.
end
(),
&
IsGlobPattern
);
const
auto
exact_match_patterns_begin
=
std
::
partition
(
exact_match_patterns_
.
insert
(
exact_match_pattern_begin
,
all_patterns
.
begin
(),
all_patterns
.
end
(),
&
IsGlobPattern
);
glob_patterns_
.
end
());
glob_patterns_
.
erase
(
exact_match_pattern_begin
,
glob_patterns_
.
end
());
glob_patterns_
.
reserve
(
exact_match_patterns_begin
-
all_patterns
.
begin
());
std
::
move
(
all_patterns
.
begin
(),
exact_match_patterns_begin
,
std
::
inserter
(
glob_patterns_
,
glob_patterns_
.
begin
()));
std
::
move
(
exact_match_patterns_begin
,
all_patterns
.
end
(),
std
::
inserter
(
exact_match_patterns_
,
exact_match_patterns_
.
begin
()));
}
}
// Returns true if and only if name matches at least one of the patterns in
// Returns true if and only if name matches at least one of the patterns in
...
...
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