Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
clapp
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
libclapp
clapp
Commits
bd6b59b6
Commit
bd6b59b6
authored
2 years ago
by
Martin Wölzer
Browse files
Options
Downloads
Patches
Plain Diff
examples/container_example.cpp: fixed code and tests
parent
c72be7b9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/container_example.cpp
+2
-5
2 additions, 5 deletions
examples/container_example.cpp
examples/test_container_example.sh
+4
-4
4 additions, 4 deletions
examples/test_container_example.sh
with
6 additions
and
9 deletions
examples/container_example.cpp
+
2
−
5
View file @
bd6b59b6
...
...
@@ -10,9 +10,6 @@
clapp
::
value
::
found_func_t
::
ret_t
print_version_and_exit
(
const
std
::
string
&
option
);
// clapp::value::found_func_t::ret_t print_not_implemented_and_exit(
// const std::string &option);
//
class
cli_parser_t
:
public
clapp
::
basic_main_parser_t
{
public:
cli_parser_t
();
...
...
@@ -43,7 +40,7 @@ class cli_parser_t : public clapp::basic_main_parser_t {
'v'
,
"Verbose option."
,
clapp
::
min_max_value_t
<
std
::
size_t
>
{
0
,
7
},
clapp
::
default_value_t
<
std
::
size_t
>
{
2
}};
clapp
::
default_value_t
<
std
::
size_t
>
{
2
}
,
purpose_t
::
optional
};
// mandatory string option
clapp
::
string_param_option_t
string_param
{
...
...
@@ -114,7 +111,7 @@ int main(int argc, char **argv) {
}
if
(
parser
->
options
.
verbose
)
{
// if the optional verbose-option is given
.
verbose
.
given
()
)
{
// if the optional verbose-option is given
std
::
cout
<<
"verbose: "
<<
parser
->
options
.
verbose
.
value
()
<<
"
\n
"
;
}
else
{
std
::
cout
<<
"verbose: not given
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
examples/test_container_example.sh
100644 → 100755
+
4
−
4
View file @
bd6b59b6
...
...
@@ -32,7 +32,7 @@ CLAPP_EXCEPTION_REGEX='^Caught\ ClaPP-Exception:.*$'
[
"
$status
"
-eq
0
]
[
"
${
lines
[0]
}
"
=
"verbose: not given"
]
[
"
${
lines
[1]
}
"
=
"string-param: str"
]
[
"
${
lines
[2]
}
"
=
"u32-param: 15"
]
[
"
${
lines
[2]
}
"
=
"u
int
32-param: 15"
]
}
@test
"container-example: give mandatory options and i32"
{
...
...
@@ -40,15 +40,15 @@ CLAPP_EXCEPTION_REGEX='^Caught\ ClaPP-Exception:.*$'
[
"
$status
"
-eq
0
]
[
"
${
lines
[0]
}
"
=
"verbose: not given"
]
[
"
${
lines
[1]
}
"
=
"string-param: string"
]
[
"
${
lines
[2]
}
"
=
"i32-param: 8"
]
[
"
${
lines
[2]
}
"
=
"i
nt
32-param: 8"
]
}
@test
"container-example: give mandatory options i32 and verbose"
{
run ./libclapp_example_container
-s
string
--i32
17
--verbose
-v
[
"
$status
"
-eq
0
]
[
"
${
lines
[0]
}
"
=
"verbose:
2
"
]
[
"
${
lines
[0]
}
"
=
"verbose:
4
"
]
[
"
${
lines
[1]
}
"
=
"string-param: string"
]
[
"
${
lines
[2]
}
"
=
"i32-param: 17"
]
[
"
${
lines
[2]
}
"
=
"i
nt
32-param: 17"
]
}
@test
"container-example: missing int-options throw"
{
...
...
This diff is collapsed.
Click to expand it.
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