From 54b1e3a49bdfc849462723f9f308e651627caf8d Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Sat, 21 Nov 2009 03:04:38 +0000 Subject: [PATCH] added test for paranthesis checker --- .../SuggestedParenthesisCheckerTest.java | 62 +++++++++++++++++++ .../core/test/AutomatedIntegrationSuite.java | 10 +-- 2 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/checkers/sample/SuggestedParenthesisCheckerTest.java diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/checkers/sample/SuggestedParenthesisCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/checkers/sample/SuggestedParenthesisCheckerTest.java new file mode 100644 index 00000000000..f3435826592 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/checkers/sample/SuggestedParenthesisCheckerTest.java @@ -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 { + /*- + + main() { + int a=1,b=3; + if (!a<10) b=4; // error here on line 3 + } + + */ + public void test1() { + load("test1.c"); + runOnFile(); + checkErrorLine(3); + } + + /*- + + main() { + int a=1,b=3; + + if (b+a && a>b || b-a) b--; // error here on line 4 + } + + */ + public void test2() { + load("test2.c"); + runOnFile(); + checkErrorLine(4); + } + + /*- + + main() { + int a=1,b=3; + if (!(a<10)) b=4; // no error here on line 3 + } + + */ + public void test3() { + load("test3.c"); + runOnFile(); + checkNoErrors(); + } +} diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java index 48e469c8c4d..41df6b7bd78 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java @@ -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; } - - - - }