@@ -227,10 +227,15 @@ class TestCmdlineParser : public TestFixture {
227227 TEST_CASE (outputFormatText);
228228 TEST_CASE (outputFormatSarif);
229229 TEST_CASE (outputFormatXml);
230+ TEST_CASE (outputFormatXmlv2);
231+ TEST_CASE (outputFormatXmlv3);
230232 TEST_CASE (outputFormatOther);
231233 TEST_CASE (outputFormatImplicitPlist);
232234 TEST_CASE (outputFormatImplicitXml);
233235 TEST_CASE (outputFormatOverridePlist);
236+ TEST_CASE (outputFormatMixed1);
237+ TEST_CASE (outputFormatMixed2);
238+ TEST_CASE (outputFormatMixed3);
234239 TEST_CASE (premiumOptions1);
235240 TEST_CASE (premiumOptions2);
236241 TEST_CASE (premiumOptions3);
@@ -1381,11 +1386,27 @@ class TestCmdlineParser : public TestFixture {
13811386 ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
13821387 }
13831388
1389+ void outputFormatXmlv2 () {
1390+ REDIRECT;
1391+ const char * const argv[] = {" cppcheck" , " --output-format=xmlv2" , " file.cpp" };
1392+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1393+ ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
1394+ ASSERT_EQUALS (2 , settings->xml_version );
1395+ }
1396+
1397+ void outputFormatXmlv3 () {
1398+ REDIRECT;
1399+ const char * const argv[] = {" cppcheck" , " --output-format=xmlv3" , " file.cpp" };
1400+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Success, parseFromArgs (argv));
1401+ ASSERT_EQUALS_ENUM (Settings::OutputFormat::xml, settings->outputFormat );
1402+ ASSERT_EQUALS (3 , settings->xml_version );
1403+ }
1404+
13841405 void outputFormatOther () {
13851406 REDIRECT;
13861407 const char * const argv[] = {" cppcheck" , " --output-format=plist" , " file.cpp" };
13871408 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 ());
1409+ ASSERT_EQUALS (" cppcheck: error: argument to '--output-format=' must be 'text', 'sarif', 'xml' (deprecated), 'xmlv2' or 'xmlv3 '.\n " , logger->str ());
13891410 }
13901411
13911412 void outputFormatImplicitPlist () {
@@ -1411,6 +1432,27 @@ class TestCmdlineParser : public TestFixture {
14111432 ASSERT_EQUALS (" " , settings->plistOutput );
14121433 }
14131434
1435+ void outputFormatMixed1 () {
1436+ REDIRECT;
1437+ const char * const argv[] = {" cppcheck" , " --xml" , " --output-format=xml" , " file.cpp" };
1438+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1439+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1440+ }
1441+
1442+ void outputFormatMixed2 () {
1443+ REDIRECT;
1444+ const char * const argv[] = {" cppcheck" , " --output-format=xml" , " --xml" , " file.cpp" };
1445+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1446+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1447+ }
1448+
1449+ void outputFormatMixed3 () {
1450+ REDIRECT;
1451+ const char * const argv[] = {" cppcheck" , " --xml-version=2" , " --output-format=xml" , " file.cpp" };
1452+ ASSERT_EQUALS_ENUM (CmdLineParser::Result::Fail, parseFromArgs (argv));
1453+ ASSERT_EQUALS (" cppcheck: error: '--output-format' and '--xml...' may not be used in conjunction.\n " , logger->str ());
1454+ }
1455+
14141456 void premiumOptions1 () {
14151457 REDIRECT;
14161458 asPremium ();
0 commit comments