@@ -118,9 +118,11 @@ TEST_CASE("Short options", "[options]")
118
118
cxxopts::Options options (" test_short" , " - test short options" );
119
119
120
120
options.add_options ()
121
- (" a" , " a short option" , cxxopts::value<std::string>());
121
+ (" a" , " a short option" , cxxopts::value<std::string>())
122
+ (" b" , " b option" )
123
+ (" c" , " c option" , cxxopts::value<std::string>());
122
124
123
- Argv argv ({" test_short" , " -a" , " value" });
125
+ Argv argv ({" test_short" , " -a" , " value" , " -bcfoo=something " });
124
126
125
127
auto actual_argv = argv.argv ();
126
128
auto argc = argv.argc ();
@@ -131,10 +133,15 @@ TEST_CASE("Short options", "[options]")
131
133
CHECK (result[" a" ].as <std::string>() == " value" );
132
134
133
135
auto & arguments = result.arguments ();
134
- REQUIRE (arguments.size () == 1 );
136
+ REQUIRE (arguments.size () == 3 );
135
137
CHECK (arguments[0 ].key () == " a" );
136
138
CHECK (arguments[0 ].value () == " value" );
137
139
140
+ CHECK (result.count (" b" ) == 1 );
141
+ CHECK (result.count (" c" ) == 1 );
142
+
143
+ CHECK (result[" c" ].as <std::string>() == " foo=something" );
144
+
138
145
REQUIRE_THROWS_AS (options.add_options ()(" " , " nothing option" ),
139
146
cxxopts::exceptions::invalid_option_format&);
140
147
}
@@ -703,8 +710,8 @@ TEST_CASE("Allow bad short syntax", "[options]") {
703
710
(" s,short" , " a short option" );
704
711
705
712
Argv av ({
706
- " unknown_options " ,
707
- " -some_bad_short " ,
713
+ " --ab? " ,
714
+ " -?b?#@ "
708
715
});
709
716
710
717
auto ** argv = av.argv ();
@@ -718,7 +725,7 @@ TEST_CASE("Allow bad short syntax", "[options]") {
718
725
options.allow_unrecognised_options ();
719
726
CHECK_NOTHROW (options.parse (argc, argv));
720
727
REQUIRE (argc == 2 );
721
- CHECK_THAT (argv[1 ], Catch::Equals (" -some_bad_short " ));
728
+ CHECK_THAT (argv[1 ], Catch::Equals (" -?b?#@ " ));
722
729
}
723
730
}
724
731
0 commit comments