@@ -91,16 +91,25 @@ class TestCmdlineParser : public TestFixture {
9191 std::string buf;
9292 };
9393
94+ class CmdLineParserTest : public CmdLineParser
95+ {
96+ friend class TestCmdlineParser ;
97+ public:
98+ CmdLineParserTest (CmdLineLogger &logger, Settings &settings, Suppressions &suppressions)
99+ : CmdLineParser(logger, settings, suppressions)
100+ {}
101+ };
102+
94103 std::unique_ptr<CmdLineLoggerTest> logger;
95104 std::unique_ptr<Settings> settings;
96105 std::unique_ptr<Suppressions> supprs;
97- std::unique_ptr<CmdLineParser > parser;
106+ std::unique_ptr<CmdLineParserTest > parser;
98107
99108 void prepareTestInternal () override {
100109 logger.reset (new CmdLineLoggerTest ());
101110 settings.reset (new Settings ());
102111 supprs.reset (new Suppressions ());
103- parser.reset (new CmdLineParser (*logger, *settings, *supprs));
112+ parser.reset (new CmdLineParserTest (*logger, *settings, *supprs));
104113 }
105114
106115 void teardownTestInternal () override {
@@ -616,23 +625,23 @@ class TestCmdlineParser : public TestFixture {
616625 REDIRECT;
617626 const char * const argv[] = {" cppcheck" , " file.cpp" };
618627 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
619- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
620- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () .at (0 ));
628+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
629+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames .at (0 ));
621630 }
622631
623632 void onepath () {
624633 REDIRECT;
625634 const char * const argv[] = {" cppcheck" , " src" };
626635 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
627- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
628- ASSERT_EQUALS (" src" , parser->getPathNames () .at (0 ));
636+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
637+ ASSERT_EQUALS (" src" , parser->mPathNames .at (0 ));
629638 }
630639
631640 void optionwithoutfile () {
632641 REDIRECT;
633642 const char * const argv[] = {" cppcheck" , " -v" };
634643 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
635- ASSERT_EQUALS (0 , parser->getPathNames () .size ());
644+ ASSERT_EQUALS (0 , parser->mPathNames .size ());
636645 ASSERT_EQUALS (" cppcheck: error: no C or C++ source files found.\n " , logger->str ());
637646 }
638647
@@ -1266,8 +1275,8 @@ class TestCmdlineParser : public TestFixture {
12661275 " file2.cpp\n " );
12671276 const char * const argv[] = {" cppcheck" , " --file-list=files.txt" , " file.cpp" };
12681277 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1269- ASSERT_EQUALS (3 , parser->getPathNames () .size ());
1270- auto it = parser->getPathNames () .cbegin ();
1278+ ASSERT_EQUALS (3 , parser->mPathNames .size ());
1279+ auto it = parser->mPathNames .cbegin ();
12711280 ASSERT_EQUALS (" file1.c" , *it++);
12721281 ASSERT_EQUALS (" file2.cpp" , *it++);
12731282 ASSERT_EQUALS (" file.cpp" , *it);
@@ -1285,8 +1294,8 @@ class TestCmdlineParser : public TestFixture {
12851294 RedirectInput input (" file1.c\n file2.cpp\n " );
12861295 const char * const argv[] = {" cppcheck" , " --file-list=-" , " file.cpp" };
12871296 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1288- ASSERT_EQUALS (3 , parser->getPathNames () .size ());
1289- auto it = parser->getPathNames () .cbegin ();
1297+ ASSERT_EQUALS (3 , parser->mPathNames .size ());
1298+ auto it = parser->mPathNames .cbegin ();
12901299 ASSERT_EQUALS (" file1.c" , *it++);
12911300 ASSERT_EQUALS (" file2.cpp" , *it++);
12921301 ASSERT_EQUALS (" file.cpp" , *it);
@@ -2474,8 +2483,8 @@ class TestCmdlineParser : public TestFixture {
24742483 " </project>" );
24752484 const char * const argv[] = {" cppcheck" , " --project=project.cppcheck" };
24762485 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
2477- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
2478- auto it = parser->getPathNames () .cbegin ();
2486+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
2487+ auto it = parser->mPathNames .cbegin ();
24792488 ASSERT_EQUALS (" dir" , *it);
24802489 }
24812490
@@ -3342,137 +3351,137 @@ class TestCmdlineParser : public TestFixture {
33423351 REDIRECT;
33433352 const char * const argv[] = {" cppcheck" , " -isrc" , " file.cpp" };
33443353 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3345- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3346- ASSERT_EQUALS (" src" , parser->getIgnoredPaths () [0 ]);
3347- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3348- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3354+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3355+ ASSERT_EQUALS (" src" , parser->mIgnoredPaths [0 ]);
3356+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3357+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
33493358 }
33503359
33513360 void ignorepaths2 () {
33523361 REDIRECT;
33533362 const char * const argv[] = {" cppcheck" , " -i" , " src" , " file.cpp" };
33543363 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3355- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3356- ASSERT_EQUALS (" src" , parser->getIgnoredPaths () [0 ]);
3357- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3358- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3364+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3365+ ASSERT_EQUALS (" src" , parser->mIgnoredPaths [0 ]);
3366+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3367+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
33593368 }
33603369
33613370 void ignorepaths3 () {
33623371 REDIRECT;
33633372 const char * const argv[] = {" cppcheck" , " -isrc" , " -imodule" , " file.cpp" };
33643373 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3365- ASSERT_EQUALS (2 , parser->getIgnoredPaths () .size ());
3366- ASSERT_EQUALS (" src" , parser->getIgnoredPaths () [0 ]);
3367- ASSERT_EQUALS (" module" , parser->getIgnoredPaths () [1 ]);
3368- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3369- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3374+ ASSERT_EQUALS (2 , parser->mIgnoredPaths .size ());
3375+ ASSERT_EQUALS (" src" , parser->mIgnoredPaths [0 ]);
3376+ ASSERT_EQUALS (" module" , parser->mIgnoredPaths [1 ]);
3377+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3378+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
33703379 }
33713380
33723381 void ignorepaths4 () {
33733382 REDIRECT;
33743383 const char * const argv[] = {" cppcheck" , " -i" , " src" , " -i" , " module" , " file.cpp" };
33753384 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3376- ASSERT_EQUALS (2 , parser->getIgnoredPaths () .size ());
3377- ASSERT_EQUALS (" src" , parser->getIgnoredPaths () [0 ]);
3378- ASSERT_EQUALS (" module" , parser->getIgnoredPaths () [1 ]);
3379- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3380- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3385+ ASSERT_EQUALS (2 , parser->mIgnoredPaths .size ());
3386+ ASSERT_EQUALS (" src" , parser->mIgnoredPaths [0 ]);
3387+ ASSERT_EQUALS (" module" , parser->mIgnoredPaths [1 ]);
3388+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3389+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
33813390 }
33823391
33833392 void ignorefilepaths1 () {
33843393 REDIRECT;
33853394 const char * const argv[] = {" cppcheck" , " -ifoo.cpp" , " file.cpp" };
33863395 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3387- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3388- ASSERT_EQUALS (" foo.cpp" , parser->getIgnoredPaths () [0 ]);
3389- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3390- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3396+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3397+ ASSERT_EQUALS (" foo.cpp" , parser->mIgnoredPaths [0 ]);
3398+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3399+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
33913400 }
33923401
33933402 void ignorefilepaths2 () {
33943403 REDIRECT;
33953404 const char * const argv[] = {" cppcheck" , " -isrc/foo.cpp" , " file.cpp" };
33963405 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3397- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3398- ASSERT_EQUALS (" src/foo.cpp" , parser->getIgnoredPaths () [0 ]);
3399- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3400- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3406+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3407+ ASSERT_EQUALS (" src/foo.cpp" , parser->mIgnoredPaths [0 ]);
3408+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3409+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
34013410 }
34023411
34033412 void ignorefilepaths3 () {
34043413 REDIRECT;
34053414 const char * const argv[] = {" cppcheck" , " -i" , " foo.cpp" , " file.cpp" };
34063415 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
3407- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3408- ASSERT_EQUALS (" foo.cpp" , parser->getIgnoredPaths () [0 ]);
3409- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3410- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3416+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3417+ ASSERT_EQUALS (" foo.cpp" , parser->mIgnoredPaths [0 ]);
3418+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3419+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
34113420 }
34123421
34133422 void ignorefilepaths4 () {
34143423 REDIRECT;
34153424 const char * const argv[] = {" cppcheck" , " -ifoo.cpp" , " file.cpp" };
34163425 ASSERT (!fillSettingsFromArgs (argv));
3417- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3418- ASSERT_EQUALS (" foo.cpp" , parser->getIgnoredPaths () [0 ]);
3419- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3420- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3426+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3427+ ASSERT_EQUALS (" foo.cpp" , parser->mIgnoredPaths [0 ]);
3428+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3429+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
34213430 TODO_ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n " , " cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34223431 }
34233432
34243433 void ignorefilepaths5 () {
34253434 REDIRECT;
34263435 const char * const argv[] = {" cppcheck" , " -ifile.cpp" , " file.cpp" };
34273436 ASSERT (!fillSettingsFromArgs (argv));
3428- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3429- ASSERT_EQUALS (" file.cpp" , parser->getIgnoredPaths () [0 ]);
3430- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3431- ASSERT_EQUALS (" file.cpp" , parser->getPathNames () [0 ]);
3437+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3438+ ASSERT_EQUALS (" file.cpp" , parser->mIgnoredPaths [0 ]);
3439+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3440+ ASSERT_EQUALS (" file.cpp" , parser->mPathNames [0 ]);
34323441 ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34333442 }
34343443
34353444 void ignorefilepaths6 () {
34363445 REDIRECT;
34373446 const char * const argv[] = {" cppcheck" , " -isrc/file.cpp" , " src/file.cpp" };
34383447 ASSERT (!fillSettingsFromArgs (argv));
3439- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3440- ASSERT_EQUALS (" src/file.cpp" , parser->getIgnoredPaths () [0 ]);
3441- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3442- ASSERT_EQUALS (" src/file.cpp" , parser->getPathNames () [0 ]);
3448+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3449+ ASSERT_EQUALS (" src/file.cpp" , parser->mIgnoredPaths [0 ]);
3450+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3451+ ASSERT_EQUALS (" src/file.cpp" , parser->mPathNames [0 ]);
34433452 ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34443453 }
34453454
34463455 void ignorefilepaths7 () {
34473456 REDIRECT;
34483457 const char * const argv[] = {" cppcheck" , " -isrc\\ file.cpp" , " src/file.cpp" };
34493458 ASSERT (!fillSettingsFromArgs (argv));
3450- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3451- ASSERT_EQUALS (" src/file.cpp" , parser->getIgnoredPaths () [0 ]);
3452- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3453- ASSERT_EQUALS (" src/file.cpp" , parser->getPathNames () [0 ]);
3459+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3460+ ASSERT_EQUALS (" src/file.cpp" , parser->mIgnoredPaths [0 ]);
3461+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3462+ ASSERT_EQUALS (" src/file.cpp" , parser->mPathNames [0 ]);
34543463 ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34553464 }
34563465
34573466 void ignorefilepaths8 () {
34583467 REDIRECT;
34593468 const char * const argv[] = {" cppcheck" , " -isrc/file.cpp" , " src\\ file.cpp" };
34603469 ASSERT (!fillSettingsFromArgs (argv));
3461- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3462- ASSERT_EQUALS (" src/file.cpp" , parser->getIgnoredPaths () [0 ]);
3463- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3464- ASSERT_EQUALS (" src/file.cpp" , parser->getPathNames () [0 ]);
3470+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3471+ ASSERT_EQUALS (" src/file.cpp" , parser->mIgnoredPaths [0 ]);
3472+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3473+ ASSERT_EQUALS (" src/file.cpp" , parser->mPathNames [0 ]);
34653474 ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34663475 }
34673476
34683477 void ignorefilepaths9 () {
34693478 REDIRECT;
34703479 const char * const argv[] = {" cppcheck" , " -isrc\\ " , " src\\ file.cpp" };
34713480 ASSERT (!fillSettingsFromArgs (argv));
3472- ASSERT_EQUALS (1 , parser->getIgnoredPaths () .size ());
3473- ASSERT_EQUALS (" src/" , parser->getIgnoredPaths () [0 ]);
3474- ASSERT_EQUALS (1 , parser->getPathNames () .size ());
3475- ASSERT_EQUALS (" src/file.cpp" , parser->getPathNames () [0 ]);
3481+ ASSERT_EQUALS (1 , parser->mIgnoredPaths .size ());
3482+ ASSERT_EQUALS (" src/" , parser->mIgnoredPaths [0 ]);
3483+ ASSERT_EQUALS (1 , parser->mPathNames .size ());
3484+ ASSERT_EQUALS (" src/file.cpp" , parser->mPathNames [0 ]);
34763485 ASSERT_EQUALS (" cppcheck: error: could not find or open any of the paths given.\n cppcheck: Maybe all paths were ignored?\n " , logger->str ());
34773486 }
34783487
0 commit comments