Skip to content
Snippets Groups Projects
Commit bd6b59b6 authored by Martin Wölzer's avatar Martin Wölzer
Browse files

examples/container_example.cpp: fixed code and tests

parent c72be7b9
No related branches found
No related tags found
No related merge requests found
......@@ -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";
......
......@@ -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]}" = "uint32-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]}" = "int32-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]}" = "int32-param: 17" ]
}
@test "container-example: missing int-options throw" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment