1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Fixed few failing Codan tests.

This commit is contained in:
Sergey Prigogin 2012-02-10 17:37:35 -08:00
parent da28cc19fc
commit 8034e44101
4 changed files with 14 additions and 18 deletions

View file

@ -10,14 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.internal.checkers; package org.eclipse.cdt.codan.core.internal.checkers;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.test.CheckerTestCase; import org.eclipse.cdt.codan.core.test.CheckerTestCase;
import org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker; import org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import java.io.File;
import java.io.IOException;
/** /**
* Test for {@see StatementHasNoEffectChecker} class * Test for {@see StatementHasNoEffectChecker} class
* *
@ -94,19 +94,18 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase {
checkNoErrors(); checkNoErrors();
} }
/* first file */
// main() { // main() {
// int a; // int a;
// +a; // error here on line 3 // +a; // error here on line 3
// } // }
/* second file */
// foo() { // foo() {
// int a; // int a;
// //
// +a; // error here on line 4 // +a; // error here on line 4
// } // }
/* this test is using two files */
public void test2FilesUnaryExpression() throws IOException { public void test2FilesUnaryExpression() throws IOException {
/* This test is using two files */
CharSequence[] code = getContents(2); CharSequence[] code = getContents(2);
File f1 = loadcode(code[0].toString()); File f1 = loadcode(code[0].toString());
File f2 = loadcode(code[1].toString()); File f2 = loadcode(code[1].toString());

View file

@ -16,8 +16,8 @@ import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution;
/** /**
* @author Tomasz Wesolowski * @author Tomasz Wesolowski
*/ */
@SuppressWarnings("restriction")
public class CatchByReferenceQuickFixTest extends QuickFixTestCase { public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
@ -41,7 +41,6 @@ public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
// } catch (C exception) { // } catch (C exception) {
// } // }
// } // }
@SuppressWarnings("restriction")
public void testCatchByReference() throws Exception { public void testCatchByReference() throws Exception {
setQuickFix(new CatchByReferenceQuickFix()); setQuickFix(new CatchByReferenceQuickFix());
loadcode(getAboveComment()); loadcode(getAboveComment());
@ -56,7 +55,6 @@ public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
// } catch (C) { // } catch (C) {
// } // }
// } // }
@SuppressWarnings("restriction")
public void testCatchByReferenceNoDeclName() throws Exception { public void testCatchByReferenceNoDeclName() throws Exception {
setQuickFix(new CatchByReferenceQuickFix()); setQuickFix(new CatchByReferenceQuickFix());
loadcode(getAboveComment()); loadcode(getAboveComment());
@ -71,7 +69,6 @@ public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
// } catch (C exception) { // } catch (C exception) {
// } // }
// } // }
@SuppressWarnings("restriction")
public void testCatchByConstReference() throws Exception { public void testCatchByConstReference() throws Exception {
setQuickFix(new CatchByConstReferenceQuickFix()); setQuickFix(new CatchByConstReferenceQuickFix());
loadcode(getAboveComment()); loadcode(getAboveComment());
@ -86,7 +83,6 @@ public class CatchByReferenceQuickFixTest extends QuickFixTestCase {
// } catch (C) { // } catch (C) {
// } // }
// } // }
@SuppressWarnings("restriction")
public void testCatchByConstReferenceNoDeclName() throws Exception { public void testCatchByConstReferenceNoDeclName() throws Exception {
setQuickFix(new CatchByConstReferenceQuickFix()); setQuickFix(new CatchByConstReferenceQuickFix());
loadcode(getAboveComment()); loadcode(getAboveComment());

View file

@ -39,17 +39,16 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase {
// @file:header.h // @file:header.h
// int foo(); // int foo();
/* ---- */
// @file:main.c // @file:main.c
// #include "header.h" // #include "header.h"
// main() { // main() {
// foo(); // foo();
// } // }
/*
* this test is using two files, there was not actually bugs here so
* quick fix is not called
*/
public void test2FilesExample() throws Exception { public void test2FilesExample() throws Exception {
/*
* There are no problems in either of the two files, so quick fix is not called.
*/
CharSequence[] code = getContents(2); CharSequence[] code = getContents(2);
File f1 = loadcode(code[0].toString()); File f1 = loadcode(code[0].toString());
File f2 = loadcode(code[1].toString()); File f2 = loadcode(code[1].toString());

View file

@ -117,7 +117,7 @@ public class TestSourceReader {
if (line.startsWith("//")) { if (line.startsWith("//")) {
content.append(line.substring(2) + "\n"); content.append(line.substring(2) + "\n");
} else { } else {
if (content.length() > 0) { if (!line.startsWith("@") && content.length() > 0) {
contents.add(content); contents.add(content);
if (sections > 0 && contents.size() == sections + 1) if (sections > 0 && contents.size() == sections + 1)
contents.remove(0); contents.remove(0);
@ -128,10 +128,12 @@ public class TestSourceReader {
if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) { if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
return contents.toArray(new StringBuilder[contents.size()]); return contents.toArray(new StringBuilder[contents.size()]);
} }
if (!line.startsWith("@")) {
contents.clear(); contents.clear();
} }
} }
} }
}
} finally { } finally {
br.close(); br.close();
} }