mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
added test for paranthesis checker
This commit is contained in:
parent
95b1911c1d
commit
54b1e3a49b
2 changed files with 64 additions and 8 deletions
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.checkers.sample;
|
||||
|
||||
import org.eclipse.cdt.codan.core.test.CheckerTestCase;
|
||||
|
||||
/**
|
||||
* Test for {@see SuggestedParenthesisChecker} class
|
||||
*
|
||||
*/
|
||||
public class SuggestedParenthesisCheckerTest extends CheckerTestCase {
|
||||
/*-
|
||||
<code file="test1.c">
|
||||
main() {
|
||||
int a=1,b=3;
|
||||
if (!a<10) b=4; // error here on line 3
|
||||
}
|
||||
</code>
|
||||
*/
|
||||
public void test1() {
|
||||
load("test1.c");
|
||||
runOnFile();
|
||||
checkErrorLine(3);
|
||||
}
|
||||
|
||||
/*-
|
||||
<code file="test2.c">
|
||||
main() {
|
||||
int a=1,b=3;
|
||||
|
||||
if (b+a && a>b || b-a) b--; // error here on line 4
|
||||
}
|
||||
</code>
|
||||
*/
|
||||
public void test2() {
|
||||
load("test2.c");
|
||||
runOnFile();
|
||||
checkErrorLine(4);
|
||||
}
|
||||
|
||||
/*-
|
||||
<code file="test3.c">
|
||||
main() {
|
||||
int a=1,b=3;
|
||||
if (!(a<10)) b=4; // no error here on line 3
|
||||
}
|
||||
</code>
|
||||
*/
|
||||
public void test3() {
|
||||
load("test3.c");
|
||||
runOnFile();
|
||||
checkNoErrors();
|
||||
}
|
||||
}
|
|
@ -15,9 +15,9 @@ import junit.framework.Test;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.codan.core.checkers.sample.StatementHasNoEffectCheckerTest;
|
||||
import org.eclipse.cdt.codan.core.checkers.sample.SuggestedParenthesisCheckerTest;
|
||||
|
||||
public class AutomatedIntegrationSuite extends TestSuite {
|
||||
|
||||
public AutomatedIntegrationSuite() {
|
||||
}
|
||||
|
||||
|
@ -34,15 +34,9 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
||||
final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite();
|
||||
|
||||
suite.addTestSuite(StatementHasNoEffectCheckerTest.class);
|
||||
|
||||
suite.addTestSuite(SuggestedParenthesisCheckerTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue