Skip to content

Commit

Permalink
Updated to Fix JENKINS-9727
Browse files Browse the repository at this point in the history
  • Loading branch information
gboissinot committed Jul 18, 2011
1 parent 95f78e1 commit 43b17b9
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 120 deletions.
132 changes: 66 additions & 66 deletions src/test/java/org/jenkinsci/plugins/cppcheck/CppcheckParserTest.java
@@ -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());
}

}
@@ -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: &quot;Test/Display/TestGenericDisplay.h&quot; not found." verbose="Include file: &quot;Test/Display/TestGenericDisplay.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="21"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Server/SuperFly.h&quot; not found." verbose="Include file: &quot;Test/Server/SuperFly.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="22"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/DispColors.h&quot; not found." verbose="Include file: &quot;Graphics/DispColors.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="23"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/TextureData.h&quot; not found." verbose="Include file: &quot;Graphics/TextureData.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="24"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/Decals.h&quot; not found." verbose="Include file: &quot;Graphics/Decals.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="25"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;InterfaceTest/InterfaceTest.hpp&quot; not found." verbose="Include file: &quot;InterfaceTest/InterfaceTest.hpp&quot; not found.">
<location file="TestGenericDisplay.cpp" line="26"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Utility/Assert.h&quot; not found." verbose="Include file: &quot;Utility/Assert.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="27"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Utility/FormatCharTesters.h&quot; not found." verbose="Include file: &quot;Utility/FormatCharTesters.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="28"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Utility/Units.h&quot; not found." verbose="Include file: &quot;Utility/Units.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="29"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestRegion.h&quot; not found." verbose="Include file: &quot;Test/Display/TestRegion.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="31"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;DisplayExec/DisplayModel.h&quot; not found." verbose="Include file: &quot;DisplayExec/DisplayModel.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="32"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestIndicatorFactory.h&quot; not found." verbose="Include file: &quot;Test/Display/TestIndicatorFactory.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="33"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestDataMonitor.h&quot; not found." verbose="Include file: &quot;Test/Display/TestDataMonitor.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="35"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestStatusBlock.h&quot; not found." verbose="Include file: &quot;Test/Display/TestStatusBlock.h&quot; 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: &quot;Test/Display/TestGenericDisplay.h&quot; not found." verbose="Include file: &quot;Test/Display/TestGenericDisplay.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="21"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Server/SuperFly.h&quot; not found." verbose="Include file: &quot;Test/Server/SuperFly.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="22"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/DispColors.h&quot; not found." verbose="Include file: &quot;Graphics/DispColors.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="23"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/TextureData.h&quot; not found." verbose="Include file: &quot;Graphics/TextureData.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="24"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Graphics/Decals.h&quot; not found." verbose="Include file: &quot;Graphics/Decals.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="25"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;InterfaceTest/InterfaceTest.hpp&quot; not found." verbose="Include file: &quot;InterfaceTest/InterfaceTest.hpp&quot; not found.">
<location file="TestGenericDisplay.cpp" line="26"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Utility/Assert.h&quot; not found." verbose="Include file: &quot;Utility/Assert.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="27"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Utility/FormatCharTesters.h&quot; not found." verbose="Include file: &quot;Utility/FormatCharTesters.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="28"/>
</error>
<error id="missingInclude" severity="warning" msg="Include file: &quot;Utility/Units.h&quot; not found." verbose="Include file: &quot;Utility/Units.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="29"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestRegion.h&quot; not found." verbose="Include file: &quot;Test/Display/TestRegion.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="31"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;DisplayExec/DisplayModel.h&quot; not found." verbose="Include file: &quot;DisplayExec/DisplayModel.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="32"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestIndicatorFactory.h&quot; not found." verbose="Include file: &quot;Test/Display/TestIndicatorFactory.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="33"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestDataMonitor.h&quot; not found." verbose="Include file: &quot;Test/Display/TestDataMonitor.h&quot; not found.">
<location file="TestGenericDisplay.cpp" line="35"/>
</error>
<error id="missingInclude" severity="information" msg="Include file: &quot;Test/Display/TestStatusBlock.h&quot; not found." verbose="Include file: &quot;Test/Display/TestStatusBlock.h&quot; 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>

0 comments on commit 43b17b9

Please sign in to comment.