@@ -227,10 +227,13 @@ class TestCmdlineParser : public TestFixture {
227227 TEST_CASE (outputFormatText);
228228 TEST_CASE (outputFormatSarif);
229229 TEST_CASE (outputFormatXml);
230+ TEST_CASE (outputFormatXml2);
231+ TEST_CASE (outputFormatXml3);
230232 TEST_CASE (outputFormatOther);
231233 TEST_CASE (outputFormatImplicitPlist);
232234 TEST_CASE (outputFormatImplicitXml);
233235 TEST_CASE (outputFormatOverridePlist);
236+ TEST_CASE (outputFormatMixed);
234237 TEST_CASE (premiumOptions1);
235238 TEST_CASE (premiumOptions2);
236239 TEST_CASE (premiumOptions3);
@@ -1381,11 +1384,27 @@ class TestCmdlineParser : public TestFixture {
13811384 ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
13821385 }
13831386
1387+ void outputFormatXml2 () {
1388+ REDIRECT;
1389+ const char * const argv[] = {" cppcheck" , " --output-format=xml2" , " file.cpp" };
1390+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1391+ ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
1392+ ASSERT_EQUALS (2 , settings->xml_version );
1393+ }
1394+
1395+ void outputFormatXml3 () {
1396+ REDIRECT;
1397+ const char * const argv[] = {" cppcheck" , " --output-format=xml3" , " file.cpp" };
1398+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1399+ ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
1400+ ASSERT_EQUALS (3 , settings->xml_version );
1401+ }
1402+
13841403 void outputFormatOther () {
13851404 REDIRECT;
13861405 const char * const argv[] = {" cppcheck" , " --output-format=plist" , " file.cpp" };
13871406 ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1388- ASSERT_EQUALS (" cppcheck: error: argument to '--output-format=' must be 'text', 'sarif' or 'xml '.\n " , logger->str ());
1407+ ASSERT_EQUALS (" cppcheck: error: argument to '--output-format=' must be 'text', 'sarif', 'xml' (deprecated), 'xml2' or 'xml3 '.\n " , logger->str ());
13891408 }
13901409
13911410 void outputFormatImplicitPlist () {
@@ -1411,6 +1430,25 @@ class TestCmdlineParser : public TestFixture {
14111430 ASSERT_EQUALS (" " , settings->plistOutput );
14121431 }
14131432
1433+ void outputFormatMixed () {
1434+ REDIRECT;
1435+ {
1436+ const char * const argv[] = {" cppcheck" , " --xml" , " --output-format=xml" , " file.cpp" };
1437+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1438+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1439+ }
1440+ {
1441+ const char * const argv[] = {" cppcheck" , " --output-format=xml" , " --xml" , " file.cpp" };
1442+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1443+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1444+ }
1445+ {
1446+ const char * const argv[] = {" cppcheck" , " --xml-version=2" , " --output-format=xml" , " file.cpp" };
1447+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1448+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1449+ }
1450+ }
1451+
14141452 void premiumOptions1 () {
14151453 REDIRECT;
14161454 asPremium ();
0 commit comments