Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95f78e1
commit 43b17b9
Showing
2 changed files
with
120 additions
and
120 deletions.
There are no files selected for viewing
132 changes: 66 additions & 66 deletions
132
src/test/java/org/jenkinsci/plugins/cppcheck/CppcheckParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
package org.jenkinsci.plugins.cppcheck; | ||
|
||
import com.thalesgroup.hudson.plugins.cppcheck.CppcheckReport; | ||
import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile; | ||
import com.thalesgroup.hudson.plugins.cppcheck.parser.CppcheckParser; | ||
import junit.framework.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CppcheckParserTest { | ||
|
||
|
||
CppcheckParser cppcheckParser; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
cppcheckParser = new CppcheckParser(); | ||
} | ||
|
||
@Test | ||
public void testcppcheck1Version2() throws Exception { | ||
processCppcheck("version2/testCppcheck.xml", 16, 0, 0, 0, 2, 14); | ||
} | ||
|
||
private void processCppcheck(String filename, | ||
int nbErrors, | ||
int nbSeveritiesPossibleError, | ||
int nbSeveritiesPossibleStyle, | ||
int nbStyleErrors, | ||
int nbSeveritiesError, | ||
int nbSeveritiesNoCategory) throws Exception { | ||
|
||
CppcheckReport cppcheckReport = cppcheckParser.parse(new File(this.getClass().getResource(filename).toURI())); | ||
|
||
List<CppcheckFile> everyErrors = cppcheckReport.getEverySeverities(); | ||
List<CppcheckFile> possibileErrorSeverities = cppcheckReport.getPossibleErrorSeverities(); | ||
List<CppcheckFile> styleErrors = cppcheckReport.getStyleSeverities(); | ||
List<CppcheckFile> possibleStyleSeverities = cppcheckReport.getPossibleStyleSeverities(); | ||
List<CppcheckFile> errorSeverities = cppcheckReport.getErrorSeverities(); | ||
List<CppcheckFile> noCategorySeverities = cppcheckReport.getNoCategorySeverities(); | ||
|
||
assert possibileErrorSeverities != null; | ||
assert possibleStyleSeverities != null; | ||
assert errorSeverities != null; | ||
assert everyErrors != null; | ||
assert styleErrors != null; | ||
assert noCategorySeverities != null; | ||
|
||
Assert.assertEquals("Wrong computing of list of errors", everyErrors.size(), | ||
noCategorySeverities.size() + possibleStyleSeverities.size() + errorSeverities.size() + possibileErrorSeverities.size() + styleErrors.size()); | ||
|
||
Assert.assertEquals("Wrong total number of errors", nbErrors, everyErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible error'", nbSeveritiesPossibleError, possibileErrorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible style'", nbSeveritiesPossibleStyle, possibleStyleSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'style'", nbStyleErrors, styleErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'error'", nbSeveritiesError, errorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors with no category", nbSeveritiesNoCategory, noCategorySeverities.size()); | ||
} | ||
|
||
} | ||
package org.jenkinsci.plugins.cppcheck; | ||
|
||
import com.thalesgroup.hudson.plugins.cppcheck.CppcheckReport; | ||
import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckFile; | ||
import com.thalesgroup.hudson.plugins.cppcheck.parser.CppcheckParser; | ||
import junit.framework.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CppcheckParserTest { | ||
|
||
|
||
CppcheckParser cppcheckParser; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
cppcheckParser = new CppcheckParser(); | ||
} | ||
|
||
@Test | ||
public void testcppcheck1Version2() throws Exception { | ||
processCppcheck("version2/testCppcheck.xml", 16, 1, 13, 0, 2, 0); | ||
} | ||
|
||
private void processCppcheck(String filename, | ||
int nbErrors, | ||
int nbSeveritiesPossibleError, | ||
int nbSeveritiesPossibleStyle, | ||
int nbStyleErrors, | ||
int nbSeveritiesError, | ||
int nbSeveritiesNoCategory) throws Exception { | ||
|
||
CppcheckReport cppcheckReport = cppcheckParser.parse(new File(this.getClass().getResource(filename).toURI())); | ||
|
||
List<CppcheckFile> everyErrors = cppcheckReport.getEverySeverities(); | ||
List<CppcheckFile> possibileErrorSeverities = cppcheckReport.getPossibleErrorSeverities(); | ||
List<CppcheckFile> styleErrors = cppcheckReport.getStyleSeverities(); | ||
List<CppcheckFile> possibleStyleSeverities = cppcheckReport.getPossibleStyleSeverities(); | ||
List<CppcheckFile> errorSeverities = cppcheckReport.getErrorSeverities(); | ||
List<CppcheckFile> noCategorySeverities = cppcheckReport.getNoCategorySeverities(); | ||
|
||
assert possibileErrorSeverities != null; | ||
assert possibleStyleSeverities != null; | ||
assert errorSeverities != null; | ||
assert everyErrors != null; | ||
assert styleErrors != null; | ||
assert noCategorySeverities != null; | ||
|
||
Assert.assertEquals("Wrong computing of list of errors", everyErrors.size(), | ||
noCategorySeverities.size() + possibleStyleSeverities.size() + errorSeverities.size() + possibileErrorSeverities.size() + styleErrors.size()); | ||
|
||
Assert.assertEquals("Wrong total number of errors", nbErrors, everyErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible error'", nbSeveritiesPossibleError, possibileErrorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'possible style'", nbSeveritiesPossibleStyle, possibleStyleSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'style'", nbStyleErrors, styleErrors.size()); | ||
Assert.assertEquals("Wrong total number of errors for the severity 'error'", nbSeveritiesError, errorSeverities.size()); | ||
Assert.assertEquals("Wrong total number of errors with no category", nbSeveritiesNoCategory, noCategorySeverities.size()); | ||
} | ||
|
||
} |
108 changes: 54 additions & 54 deletions
108
src/test/resources/org/jenkinsci/plugins/cppcheck/version2/testCppcheck.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<results version="2"> | ||
<cppcheck version="1.48"/> | ||
<errors> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestGenericDisplay.h" not found." verbose="Include file: "Test/Display/TestGenericDisplay.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="21"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Server/SuperFly.h" not found." verbose="Include file: "Test/Server/SuperFly.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="22"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/DispColors.h" not found." verbose="Include file: "Graphics/DispColors.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="23"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/TextureData.h" not found." verbose="Include file: "Graphics/TextureData.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="24"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/Decals.h" not found." verbose="Include file: "Graphics/Decals.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="25"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "InterfaceTest/InterfaceTest.hpp" not found." verbose="Include file: "InterfaceTest/InterfaceTest.hpp" not found."> | ||
<location file="TestGenericDisplay.cpp" line="26"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/Assert.h" not found." verbose="Include file: "Utility/Assert.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="27"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/FormatCharTesters.h" not found." verbose="Include file: "Utility/FormatCharTesters.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="28"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/Units.h" not found." verbose="Include file: "Utility/Units.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="29"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestRegion.h" not found." verbose="Include file: "Test/Display/TestRegion.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="31"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "DisplayExec/DisplayModel.h" not found." verbose="Include file: "DisplayExec/DisplayModel.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="32"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestIndicatorFactory.h" not found." verbose="Include file: "Test/Display/TestIndicatorFactory.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="33"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestDataMonitor.h" not found." verbose="Include file: "Test/Display/TestDataMonitor.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="35"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestStatusBlock.h" not found." verbose="Include file: "Test/Display/TestStatusBlock.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="38"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
</errors> | ||
</results> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<results version="2"> | ||
<cppcheck version="1.48"/> | ||
<errors> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestGenericDisplay.h" not found." verbose="Include file: "Test/Display/TestGenericDisplay.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="21"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Server/SuperFly.h" not found." verbose="Include file: "Test/Server/SuperFly.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="22"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/DispColors.h" not found." verbose="Include file: "Graphics/DispColors.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="23"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/TextureData.h" not found." verbose="Include file: "Graphics/TextureData.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="24"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Graphics/Decals.h" not found." verbose="Include file: "Graphics/Decals.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="25"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "InterfaceTest/InterfaceTest.hpp" not found." verbose="Include file: "InterfaceTest/InterfaceTest.hpp" not found."> | ||
<location file="TestGenericDisplay.cpp" line="26"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/Assert.h" not found." verbose="Include file: "Utility/Assert.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="27"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Utility/FormatCharTesters.h" not found." verbose="Include file: "Utility/FormatCharTesters.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="28"/> | ||
</error> | ||
<error id="missingInclude" severity="warning" msg="Include file: "Utility/Units.h" not found." verbose="Include file: "Utility/Units.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="29"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestRegion.h" not found." verbose="Include file: "Test/Display/TestRegion.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="31"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "DisplayExec/DisplayModel.h" not found." verbose="Include file: "DisplayExec/DisplayModel.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="32"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestIndicatorFactory.h" not found." verbose="Include file: "Test/Display/TestIndicatorFactory.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="33"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestDataMonitor.h" not found." verbose="Include file: "Test/Display/TestDataMonitor.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="35"/> | ||
</error> | ||
<error id="missingInclude" severity="information" msg="Include file: "Test/Display/TestStatusBlock.h" not found." verbose="Include file: "Test/Display/TestStatusBlock.h" not found."> | ||
<location file="TestGenericDisplay.cpp" line="38"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TEST;TEST_VM2;TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
<error id="syntaxError" severity="error" msg="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'." verbose="Invalid number of charTestter ({) when these macros are defined: 'TODO_TESTS_REFACTOR'."> | ||
<location file="TestGenericDisplay.cpp" line="1600"/> | ||
</error> | ||
</errors> | ||
</results> |