Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Utils
KWSys
Commits
09942f51
Commit
09942f51
authored
4 years ago
by
Ben Boeckel
Committed by
Brad King
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
testSystemTools: add tests for SplitString
parent
95a97253
No related branches found
Branches containing commit
No related tags found
1 merge request
!178
Split string start edge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
testSystemTools.cxx
+38
-0
38 additions, 0 deletions
testSystemTools.cxx
with
38 additions
and
0 deletions
testSystemTools.cxx
+
38
−
0
View file @
09942f51
...
...
@@ -1120,6 +1120,42 @@ static bool CheckURLParsing()
return
ret
;
}
static
bool
CheckSplitString
()
{
bool
ret
=
true
;
auto
check_split
=
[](
std
::
string
const
&
input
,
std
::
initializer_list
<
const
char
*>
expected
)
->
bool
{
auto
const
components
=
kwsys
::
SystemTools
::
SplitString
(
input
,
'/'
);
if
(
components
.
size
()
!=
expected
.
size
())
{
std
::
cerr
<<
"Incorrect split count for "
<<
input
<<
": "
<<
components
.
size
()
<<
std
::
endl
;
return
false
;
}
size_t
i
=
0
;
for
(
auto
&
part
:
expected
)
{
if
(
components
[
i
]
!=
part
)
{
std
::
cerr
<<
"Incorrect split component "
<<
i
<<
" for "
<<
input
<<
": "
<<
components
[
i
]
<<
std
::
endl
;
return
false
;
}
++
i
;
}
return
true
;
};
// No separators
ret
&=
check_split
(
"nosep"
,
{
"nosep"
});
// Simple
ret
&=
check_split
(
"first/second"
,
{
"first"
,
"second"
});
// Separator at beginning
ret
&=
check_split
(
"/starts/sep"
,
{
""
,
"starts"
,
"sep"
});
// Separator at end
ret
&=
check_split
(
"ends/sep/"
,
{
"ends"
,
"sep"
,
""
});
return
ret
;
}
int
testSystemTools
(
int
,
char
*
[])
{
bool
res
=
true
;
...
...
@@ -1169,5 +1205,7 @@ int testSystemTools(int, char* [])
res
&=
CheckURLParsing
();
res
&=
CheckSplitString
();
return
res
?
0
:
1
;
}
This diff is collapsed.
Click to expand it.
Brad King
@brad.king
mentioned in commit
b62956f5
·
4 years ago
mentioned in commit
b62956f5
mentioned in commit b62956f5d70fef750e8414342f1566a29e8e7899
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment