@@ -262,17 +262,19 @@ void CppCommandLineTest::parse()
262262{
263263 {
264264 SCENARIO (" Single positional option" )
265- std::vector<const char *> args{" value" };
265+ std::vector<const char *> args{" ./app.exe " , " value" };
266266 cppcommandline::Parser parser;
267267 std::string value;
268268 parser.option ().bindTo (value);
269269 parser.parse (static_cast <int >(args.size ()), const_cast <char **>(args.data ()));
270270 QCOMPARE (value, std::string (" value" ));
271+ QCOMPARE (parser.command (), std::string (" ./app.exe" ));
272+ QCOMPARE (parser.applicationName (), std::string (" app" ));
271273 }
272274
273275 {
274276 SCENARIO (" Multiple positional options" )
275- std::vector<const char *> args{" value" , " -10" , " 5.5" };
277+ std::vector<const char *> args{" ./app " , " value" , " -10" , " 5.5" };
276278 cppcommandline::Parser parser;
277279 std::string value;
278280 int iValue = 0 ;
@@ -288,7 +290,7 @@ void CppCommandLineTest::parse()
288290
289291 {
290292 SCENARIO (" Single long name option" )
291- std::vector<const char *> args{" --value" };
293+ std::vector<const char *> args{" ./app " , " --value" };
292294 cppcommandline::Parser parser;
293295 bool value;
294296 parser.option (" value" ).bindTo (value);
@@ -298,7 +300,7 @@ void CppCommandLineTest::parse()
298300
299301 {
300302 SCENARIO (" Multiple long name options" )
301- std::vector<const char *> args{" --value" , " --option=file" , " --yetanother" , " 10" };
303+ std::vector<const char *> args{" ./app " , " --value" , " --option=file" , " --yetanother" , " 10" };
302304 cppcommandline::Parser parser;
303305 bool value;
304306 std::string option;
@@ -314,7 +316,7 @@ void CppCommandLineTest::parse()
314316
315317 {
316318 SCENARIO (" Single short name option" )
317- std::vector<const char *> args{" -v" };
319+ std::vector<const char *> args{" ./app " , " -v" };
318320 cppcommandline::Parser parser;
319321 bool value;
320322 parser.option (" value" ).asShortName (" v" ).bindTo (value);
@@ -324,7 +326,7 @@ void CppCommandLineTest::parse()
324326
325327 {
326328 SCENARIO (" Multiple short name options" )
327- std::vector<const char *> args{" -v" , " -o=file" , " -y" , " 10" };
329+ std::vector<const char *> args{" ./app " , " -v" , " -o=file" , " -y" , " 10" };
328330 cppcommandline::Parser parser;
329331 bool value;
330332 std::string option;
@@ -340,7 +342,7 @@ void CppCommandLineTest::parse()
340342
341343 {
342344 SCENARIO (" Mixed options" )
343- std::vector<const char *> args{" -v" , " -o=file" , " --yetanother" , " 10" , " somefile" };
345+ std::vector<const char *> args{" ./app " , " -v" , " -o=file" , " --yetanother" , " 10" , " somefile" };
344346 cppcommandline::Parser parser;
345347 bool value;
346348 std::string option;
@@ -362,13 +364,13 @@ void CppCommandLineTest::parseFailed()
362364{
363365 {
364366 SCENARIO (" Unmatched argument" )
365- std::vector<const char *> args{" -v" };
367+ std::vector<const char *> args{" ./app " , " -v" };
366368 QVERIFY_EXCEPTION_THROWN (cppcommandline::Parser ().parse (static_cast <int >(args.size ()), const_cast <char **>(args.data ())), std::logic_error);
367369 }
368370
369371 {
370372 SCENARIO (" Unmatched required option" )
371- std::vector<const char *> args{" -v" };
373+ std::vector<const char *> args{" ./app " , " -v" };
372374 cppcommandline::Parser parser;
373375 parser.option (" longName" ).asShortName (" v" );
374376 parser.option ().required ();
@@ -377,7 +379,7 @@ void CppCommandLineTest::parseFailed()
377379
378380 {
379381 SCENARIO (" Type mismatch" )
380- std::vector<const char *> args{" -v=hello" };
382+ std::vector<const char *> args{" ./app " , " -v=hello" };
381383 cppcommandline::Parser parser;
382384 int value = 0 ;
383385 parser.option (" value" ).asShortName (" v" ).bindTo (value);
@@ -386,7 +388,7 @@ void CppCommandLineTest::parseFailed()
386388
387389 {
388390 SCENARIO (" Missing value" )
389- std::vector<const char *> args{" -v" };
391+ std::vector<const char *> args{" ./app " , " -v" };
390392 cppcommandline::Parser parser;
391393 int value = 0 ;
392394 parser.option (" value" ).asShortName (" v" ).bindTo (value);
0 commit comments