From dc1e7535ae9bf445a3f4be182c7ed54639ff11f0 Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Mon, 24 May 2010 21:52:00 +0000 Subject: [PATCH] Renamed a test case to match the checker --- .../internal/checkers/ReturnCheckerTest.java | 89 +++++++++++++++++++ .../core/test/AutomatedIntegrationSuite.java | 4 +- 2 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java 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 new file mode 100644 index 00000000000..679583426aa --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnCheckerTest.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * 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 + * Felipe Martinez - ReturnCheckerTest implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.core.internal.checkers; + +import org.eclipse.cdt.codan.core.test.CheckerTestCase; + +/** + * Test for {@see ReturnCheckerTest} class + * + */ +public class ReturnCheckerTest extends CheckerTestCase { + + +// dummy() { +// return; // error here on line 2 +// } + public void testDummyFunction() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); // because return type if not defined, usually people don't care + } + + +// void void_function(void) { +// return; // no error here +// } + public void testVoidFunction() { + loadCodeAndRun(getAboveComment()); + checkNoErrors(); + } + + +// int integer_return_function(void) { +// if (global) { +// if (global == 100) { +// return; // error here on line 4 +// } +// } +// } + public void testBasicTypeFunction() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(4); + } + +// +// struct My_Struct { +// int a; +// }; +// +// struct My_Struct struct_return_function(void) { +// return; // error here on line 6 +// } + public void testUserDefinedFunction() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(6); + } + + +// typedef unsigned int uint8_t; +// +// uint8_t return_typedef(void) { +// return; // error here on line 4 +// } + public void testTypedefReturnFunction() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(4); + } + + +// typedef unsigned int uint8_t; +// +// uint8_t (*return_fp_no_typedef(void))(void) +// { +// return; // error here on line 5 +// } + public void testFunctionPointerReturnFunction() { + loadCodeAndRun(getAboveComment()); + checkErrorLine(5); + } + +} \ No newline at end of file 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 cfaa138dd5f..92030753f8c 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,7 +15,7 @@ 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.ReturnCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.StatementHasNoEffectCheckerTest; import org.eclipse.cdt.codan.core.internal.checkers.SuggestedParenthesisCheckerTest; @@ -39,7 +39,7 @@ public class AutomatedIntegrationSuite extends TestSuite { final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite(); suite.addTestSuite(StatementHasNoEffectCheckerTest.class); suite.addTestSuite(SuggestedParenthesisCheckerTest.class); - suite.addTestSuite(ExpressionRequiredInReturnCheckerTest.class); + suite.addTestSuite(ReturnCheckerTest.class); suite.addTestSuite(CatchByReferenceTest.class); suite.addTest(CodanFastTestSuite.suite()); return suite;