1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Added tests for CatchByReference

This commit is contained in:
Alena Laskavaia 2010-05-13 02:05:33 +00:00
parent 81d62c4f03
commit b7eb03f5f9
2 changed files with 115 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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;
}
}