File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -620,7 +620,27 @@ void test_invalid_command_line_style_exception_msg()
620
620
}
621
621
}
622
622
623
+ void test_empty_value_inner (options_description &opts, variables_map& vm) {
624
+ positional_options_description popts;
625
+ opts.add_options ()(" foo" , value<uint32_t >()->value_name (" <time>" )->required ());
626
+ popts.add (" foo" , 1 );
627
+ vector<string> tokens{" " };
628
+ parsed_options parsed = command_line_parser (tokens)
629
+ .style (command_line_style::default_style & ~command_line_style::allow_guessing)
630
+ .options (opts)
631
+ .positional (popts)
632
+ .run ();
633
+ store (parsed, vm);
634
+ }
623
635
636
+ void test_empty_value () {
637
+ // Test that passing empty token for an option that requires integer does not result
638
+ // in out-of-range error in error reporting code.
639
+ test_exception<invalid_option_value>(
640
+ " test_empty_value" ,
641
+ " the argument for option '--foo' is invalid" ,
642
+ test_empty_value_inner);
643
+ }
624
644
625
645
int main (int /* ac*/ , char ** /* av*/ )
626
646
{
@@ -633,6 +653,7 @@ int main(int /*ac*/, char** /*av*/)
633
653
test_multiple_values_not_allowed_exception_msg ();
634
654
test_required_option_exception_msg ();
635
655
test_at_least_one_value_required_exception_msg ();
656
+ test_empty_value ();
636
657
637
658
string test_name;
638
659
string expected_message;
You can’t perform that action at this time.
0 commit comments