1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +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;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.codan.core.param.IProblemPreference;
import org.eclipse.cdt.codan.core.test.CheckerTestCase;
import org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectChecker;
import org.eclipse.core.resources.IMarker;
import java.io.File;
import java.io.IOException;
/**
* Test for {@see StatementHasNoEffectChecker} class
*
@ -94,19 +94,18 @@ public class StatementHasNoEffectCheckerTest extends CheckerTestCase {
checkNoErrors();
}
/* first file */
// main() {
// int a;
// +a; // error here on line 3
// }
/* second file */
// foo() {
// int a;
//
// +a; // error here on line 4
// }
/* this test is using two files */
public void test2FilesUnaryExpression() throws IOException {
/* This test is using two files */
CharSequence[] code = getContents(2);
File f1 = loadcode(code[0].toString());
File f2 = loadcode(code[1].toString());

View file

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

View file

@ -39,17 +39,16 @@ public class SuggestedParenthesisQuickFixTest extends QuickFixTestCase {
// @file:header.h
// int foo();
/* ---- */
// @file:main.c
// #include "header.h"
// main() {
// foo();
// }
/*
* this test is using two files, there was not actually bugs here so
* quick fix is not called
*/
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);
File f1 = loadcode(code[0].toString());
File f2 = loadcode(code[1].toString());

View file

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