mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
82fb03e1a0
commit
db6b4cf5ac
2 changed files with 42 additions and 55 deletions
|
@ -16,14 +16,9 @@ import org.eclipse.cdt.codan.core.test.CheckerTestCase;
|
|||
import org.eclipse.cdt.codan.internal.checkers.CaseBreakChecker;
|
||||
|
||||
/**
|
||||
* Test for {@link#CaseBreakChecker} class
|
||||
* Test for {@link CaseBreakChecker} class
|
||||
*/
|
||||
public class CaseBreakCheckerTest extends CheckerTestCase {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.cdt.codan.core.test.CodanTestCase#setUp()
|
||||
*/
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -34,7 +29,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// }
|
||||
// }
|
||||
|
@ -45,7 +40,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// default:
|
||||
// }
|
||||
// }
|
||||
|
@ -56,7 +51,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// }
|
||||
|
@ -68,7 +63,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// case 2:
|
||||
// b = 2;
|
||||
|
@ -83,7 +78,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// break;
|
||||
// }
|
||||
|
@ -95,7 +90,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// return;
|
||||
// }
|
||||
|
@ -107,7 +102,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(int a) {
|
||||
// while (a--)
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// continue;
|
||||
// }
|
||||
|
@ -119,7 +114,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(int a) {
|
||||
//
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// throw 1;
|
||||
// }
|
||||
|
@ -131,7 +126,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// break;
|
||||
|
@ -144,7 +139,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// break;
|
||||
// case 2:
|
||||
|
@ -159,7 +154,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// /* no break */
|
||||
// }
|
||||
|
@ -170,7 +165,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(int a, int b) {
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// switch (b) {
|
||||
// case 2:
|
||||
|
@ -187,7 +182,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// /* no break */
|
||||
|
@ -200,7 +195,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// /* no break */
|
||||
// case 2:
|
||||
|
@ -214,7 +209,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// /* no break */
|
||||
|
@ -228,7 +223,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// /* no break */
|
||||
|
@ -259,14 +254,14 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1: //err
|
||||
// // lolo
|
||||
// case 2: //err
|
||||
// case 3://err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
|
@ -279,7 +274,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// case 6: // err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
|
@ -301,7 +296,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
// b = 2;//err
|
||||
// }
|
||||
//
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2; // err
|
||||
// // lolo
|
||||
|
@ -319,7 +314,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// // lolo
|
||||
|
@ -349,7 +344,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 0:
|
||||
// switch( b ) {
|
||||
// case 2: // err
|
||||
|
@ -385,7 +380,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// b = 2;
|
||||
// }
|
||||
|
@ -399,7 +394,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a, b;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// case 2:
|
||||
// b = 2;
|
||||
|
@ -417,7 +412,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// }
|
||||
// }
|
||||
|
@ -443,7 +438,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(int a) {
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1:
|
||||
// while (a--)
|
||||
// break; // err
|
||||
|
@ -459,7 +454,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(int a) {
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 1: {
|
||||
// break;
|
||||
// }
|
||||
|
@ -476,7 +471,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
|
||||
// void foo(void) {
|
||||
// int a;
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 2:
|
||||
// break;
|
||||
// case 1:
|
||||
|
@ -494,7 +489,7 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
|
|||
}
|
||||
|
||||
// void foo(int a) {
|
||||
// switch( a ) {
|
||||
// switch (a) {
|
||||
// case 2:
|
||||
// if (a*2<10)
|
||||
// return;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Marc-Andre Laperle
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Marc-Andre Laperle
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
for (Object i : errLines) {
|
||||
checkErrorLine((Integer) i);
|
||||
}
|
||||
assertEquals("Expected number of errors "+errLines.size(),errLines.size(), markers.length);
|
||||
assertEquals("Expected number of errors " + errLines.size(),errLines.size(), markers.length);
|
||||
}
|
||||
|
||||
public IMarker checkErrorLine(int i, String problemId) {
|
||||
|
@ -90,7 +90,7 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
break;
|
||||
}
|
||||
}
|
||||
assertEquals("Error on line "+expectedLine+" is not found",Integer.valueOf(expectedLine), line);
|
||||
assertEquals("Error on line " + expectedLine + " is not found", Integer.valueOf(expectedLine), line);
|
||||
if (file != null)
|
||||
assertEquals(file.getName(), mfile);
|
||||
assertTrue(found);
|
||||
|
@ -120,18 +120,13 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
}
|
||||
|
||||
public void checkNoErrors() {
|
||||
if (markers == null || markers.length == 0) {
|
||||
// all good
|
||||
} else {
|
||||
if (markers != null && markers.length > 0) {
|
||||
IMarker m = markers[0];
|
||||
fail("Found " + markers.length + " errors but should not. First " + CodanProblemMarker.getProblemId(m) + " at line "
|
||||
+ getLine(m));
|
||||
fail("Found " + markers.length + " errors but should not. First " +
|
||||
CodanProblemMarker.getProblemId(m) + " at line " + getLine(m));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void runOnProject() {
|
||||
try {
|
||||
indexFiles();
|
||||
|
@ -151,9 +146,6 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
runCodan();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void runCodan() {
|
||||
CodanRuntime.getInstance().getBuilder().processResource(cproject.getProject(), new NullProgressMonitor());
|
||||
try {
|
||||
|
@ -169,8 +161,9 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
* @return
|
||||
*/
|
||||
protected IProblemPreference getPreference(String problemId, String paramId) {
|
||||
IProblem problem = CodanRuntime.getInstance().getCheckersRegistry().getResourceProfile(cproject.getResource())
|
||||
.findProblem(problemId);
|
||||
IProblemProfile resourceProfile =
|
||||
CodanRuntime.getInstance().getCheckersRegistry().getResourceProfile(cproject.getResource());
|
||||
IProblem problem = resourceProfile.findProblem(problemId);
|
||||
IProblemPreference pref = ((MapProblemPreference) problem.getPreference()).getChildDescriptor(paramId);
|
||||
return pref;
|
||||
}
|
||||
|
@ -219,8 +212,8 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
String pid = ids[j];
|
||||
if (p.getId().equals(pid)) {
|
||||
enabled = true;
|
||||
// Force the launch mode to FULL_BUILD to make sure we can test the problem even if by default it
|
||||
// is not set to run on FULL_BUILD
|
||||
// Force the launch mode to FULL_BUILD to make sure we can test the problem even
|
||||
// if by default it is not set to run on FULL_BUILD.
|
||||
IProblemPreference preference = p.getPreference();
|
||||
if (preference instanceof RootProblemPreference) {
|
||||
RootProblemPreference rootProblemPreference = (RootProblemPreference) preference;
|
||||
|
@ -232,6 +225,5 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
((CodanProblem) p).setEnabled(enabled);
|
||||
}
|
||||
CodanRuntime.getInstance().getCheckersRegistry().updateProfile(cproject.getProject(), profile);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue