From b7eb03f5f99e24a66123438e42bde29a7d23776e Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Thu, 13 May 2010 02:05:33 +0000 Subject: [PATCH] Added tests for CatchByReference --- .../checkers/CatchByReferenceTest.java | 113 ++++++++++++++++++ .../core/test/AutomatedIntegrationSuite.java | 2 + 2 files changed, 115 insertions(+) create mode 100644 codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java new file mode 100644 index 00000000000..b8148746065 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CatchByReferenceTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.internal.checkers; + +import org.eclipse.cdt.codan.core.test.CheckerTestCase; + +/** + * Test for {@see CatchByReference} class + * + */ +public class CatchByReferenceTest extends CheckerTestCase { + public boolean isCpp() { + return true; + } + + // void main() { + // try { + // foo(); + // } catch (int e) { + // } + // } + public void test_int() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + // class C {}; + // void main() { + // try { + // foo(); + // } catch (C e) { + // } + // } + public void test_class() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(5); + } + // class C {}; + // void main() { + // try { + // foo(); + // } catch (C & e) { + // } + // } + public void test_class_ref() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + + // class C {}; + // void main() { + // try { + // foo(); + // } catch (C * e) { + // } + // } + public void test_class_point() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + // typedef int A; + // void main() { + // try { + // foo(); + // } catch (A e) { + // } + // } + public void test_int_typedef() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + // typedef int A; + // typedef A B; + // void main() { + // try { + // foo(); + // } catch (B e) { + // } + // } + public void test_int_typedef2() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + // void main() { + // try { + // foo(); + // } catch (C e) { + // } + // } + public void test_class_unknown() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(4); + } + // class C {}; + // typedef C B; + // void main() { + // try { + // foo(); + // } catch (B e) { + // } + // } + public void test_class_typedef() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(6); + } +} 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 430b620ac04..623884569b6 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 @@ -14,6 +14,7 @@ package org.eclipse.cdt.codan.core.test; import junit.framework.Test; import junit.framework.TestSuite; +import org.eclipse.cdt.codan.core.internal.checkers.CatchByReferenceTest; import org.eclipse.cdt.codan.core.internal.checkers.ExpressionRequiredInReturnCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.StatementHasNoEffectCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest; @@ -39,6 +40,7 @@ public class AutomatedIntegrationSuite extends TestSuite { suite.addTestSuite(StatementHasNoEffectCheckerTest.class); suite.addTestSuite(SuggestedParenthesisCheckerTest.class); suite.addTestSuite(ExpressionRequiredInReturnCheckerTest.class); + suite.addTestSuite(CatchByReferenceTest.class); return suite; } }