diff options
author | Alena Laskavaia | 2010-08-27 00:47:28 +0000 |
---|---|---|
committer | Alena Laskavaia | 2010-08-27 00:47:28 +0000 |
commit | da074afa86e08b9ea953e14def164ab612c043e2 (patch) | |
tree | fef232143b2d69852f9f6d98dbabd1317a380f50 /codan/org.eclipse.cdt.codan.core.test | |
parent | 54aeb3242fd0b4ae36efdd236080328a59518ae4 (diff) | |
download | org.eclipse.cdt-da074afa86e08b9ea953e14def164ab612c043e2.tar.gz org.eclipse.cdt-da074afa86e08b9ea953e14def164ab612c043e2.tar.xz org.eclipse.cdt-da074afa86e08b9ea953e14def164ab612c043e2.zip |
Bug 323602: fixed f.p. in constructors/destructors for return checker
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core.test')
2 files changed, 46 insertions, 2 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java index ce43f168cda..bdb3ccd76bc 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java @@ -11,7 +11,9 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.internal.checkers; +import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.test.CheckerTestCase; +import org.eclipse.cdt.codan.internal.checkers.ReturnChecker; /** * Test for {@see ReturnCheckerTest} class @@ -105,4 +107,35 @@ public class ReturnCheckerTest extends CheckerTestCase { loadCodeAndRunCpp(getAboveComment()); checkErrorLine(5); } + + // class c { + // c() { + // return 0; + // } + // + // ~c() { + // return; + // } + // }; + public void testContructorRetValue() { + loadCodeAndRunCpp(getAboveComment()); + checkErrorLine(3, ReturnChecker.RET_ERR_VALUE_ID); + } + + // class c { + // c() { + // return; + // } + // + // ~c() { + // return; + // } + // }; + public void testContructor_Bug323602() { + IProblemPreference macro = getPreference(ReturnChecker.RET_NO_VALUE_ID, + ReturnChecker.PARAM_IMPLICIT); + macro.setValue(Boolean.TRUE); + loadCodeAndRunCpp(getAboveComment()); + checkNoErrors(); + } }
\ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java index d9ecb70eab1..5c4bca22a13 100644 --- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/CheckerTestCase.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.codan.core.model.IProblemReporter; import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.codan.core.param.MapProblemPreference; import org.eclipse.cdt.codan.internal.core.model.CodanProblem; +import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; @@ -35,12 +36,20 @@ public class CheckerTestCase extends CodanTestCase { return checkErrorLine(currentFile, i); } + public IMarker checkErrorLine(int i, String problemId) { + return checkErrorLine(currentFile, i, problemId); + } + + public IMarker checkErrorLine(File file, int expectedLine) { + return checkErrorLine(file, expectedLine, null); + } + /** * @param expectedLine * - line * @return */ - public IMarker checkErrorLine(File file, int expectedLine) { + public IMarker checkErrorLine(File file, int expectedLine, String problemId) { assertTrue(markers != null); assertTrue("No problems found but should", markers.length > 0); //$NON-NLS-1$ boolean found = false; @@ -62,7 +71,9 @@ public class CheckerTestCase extends CodanTestCase { fail(e.getMessage()); } mfile = m.getResource().getName(); - if (line.equals(expectedLine)) { + if (line.equals(expectedLine) + && (problemId == null || problemId + .equals(CodanProblemMarker.getProblemId(m)))) { found = true; if (file != null && !file.getName().equals(mfile)) found = false; |