diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts deleted file mode 100644 index 43703879fe8..00000000000 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts +++ /dev/null @@ -1,765 +0,0 @@ -//!Param const and reference and pointer -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -class X { -public: - bool /*$*/a(int = 100)/*$$*/ const; -}; - -//= -class X { -public: - bool a(int = 100) const; -}; - -inline bool X::a(int int1) const { -} -//!Param const and reference and pointer two params -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -class X { -public: - bool /*$*/xy(int, int i)/*$$*/ const; -}; - -//= -class X { -public: - bool xy(int, int i) const; -}; - -inline bool X::xy(int int1, int i) const { -} -//!Test if TemplateMethod stays in header -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -template -class A { -public: - /*$*/void test();/*$$*/ -}; - -//= -template -class A { -public: - void test(); -}; - -template -inline void A::test() { -} -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -//!Class template member functions -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -template -class A { -public: - A(); - /*$*/void test();/*$$*/ -}; - -template -A::A() { -} - -//= -template -class A { -public: - A(); - void test(); -}; - -template -A::A() { -} - -template -inline void A::test() { -} -//!Member class -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class Demo { - class SubClass { - /*$*/void test();/*$$*/ - }; -}; - - -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -void Demo::SubClass::test() { -} -//!Method declared in otherwise empty class without cpp file -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -class A { -public: - /*$*/void test();/*$$*/ -}; - -//= -class A { -public: - void test(); -}; - -inline void A::test() { -} -//!Method declared in otherwise empty class -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -class A { -public: - /*$*/void test();/*$$*/ -}; - -//= -class A { -public: - void test(); -}; - -//@A.cpp - -//= -void A::test() { -} -//!Implement in existing namespace -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -namespace Namespace { - -class ClassInNamespace { -public: - int test(); - /*$*/void test2();/*$$*/ -}; - -} -//@A.cpp -#include "A.h" - -namespace Namespace { - -int ClassInNamespace::test() { - return 5; -} - -} -//= -#include "A.h" - -namespace Namespace { - -int ClassInNamespace::test() { - return 5; -} - -void ClassInNamespace::test2() { -} - -} -//!Virtual method in the middle of con/destructor, without parameters and void return value -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -class A { -public: - A(); - /*$*/virtual void foo();/*$$*/ - ~A(); -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -A::A() { -} - -A::~A() { -} - -//= -#include "A.h" - -A::A() { -} - -void A::foo() { -} - -A::~A() { -} - -//!Implement a function at start of source file -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -/*$*/void function();/*$$*/ -void function_with_impl(); -//@A.cpp -void function_with_impl() { -} -//= -void function() { -} - -void function_with_impl() { -} -//!Method at end, without parameters and void return value -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -class A { -public: - A(); - /*$*/void foo();/*$$*/ -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -A::A() { -} - -//= -#include "A.h" - -A::A() { -} - -void A::foo() { -} -//!Method at beginning, without parameters, void return value and const -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -class A { -public: - /*$*/void foo() const;/*$$*/ - A(); -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -A::A() { -} - -//= -#include "A.h" - -void A::foo() const { -} - -A::A() { -} - -//!Method with int return value -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -class A { -public: - A(); - /*$*/int foo();/*$$*/ -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -A::A() { -} - -//= -#include "A.h" - -A::A() { -} - -int A::foo() { -} -//!Method with two int parameters -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -class A { -public: - A(); - /*$*/int foo(int param1, int param2);/*$$*/ -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -A::A() { -} - -//= -#include "A.h" - -A::A() { -} - -int A::foo(int param1, int param2) { -} -//!Method defined in header -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -class A { -public: - A(); - /*$*/void test();/*$$*/ -}; - -A::A() { -} - -//= -class A { -public: - A(); - void test(); -}; - -A::A() { -} - -inline void A::test() { -} -//!Implement a function at end of source file -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -void function_with_impl(); -/*$*/void function();/*$$*/ -//@A.cpp -void function_with_impl() { -} -//= -void function_with_impl() { -} - -void function() { -} -//!Implement with namespace -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -namespace Namespace { - -class ClassInNamespace { -public: - int other_test(); - /*$*/void test();/*$$*/ -}; - -} - -//@A.cpp -#include "A.h" -void Namespace::ClassInNamespace::other_test() { -} -//= -#include "A.h" -void Namespace::ClassInNamespace::other_test() { -} - -void Namespace::ClassInNamespace::test() { -} -//!Implement function within namespace -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -namespace OuterSpace { -namespace Namespace { - -int test(); -/*$*/int test2();/*$$*/ - -} -} - -//@A.cpp -#include "A.h" -namespace OuterSpace { - -int Namespace::test() { -} - -} -//= -#include "A.h" -namespace OuterSpace { - -int Namespace::test() { -} - -int Namespace::test2() { -} - -} -//!Implement function within namespaces -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -namespace OuterSpace { -namespace Namespace { - -int test(); -/*$*/int test2();/*$$*/ - -} -} - -//@A.cpp -#include "A.h" -namespace OuterSpace { -namespace Namespace { - -int test() { -} - -} -} -//= -#include "A.h" -namespace OuterSpace { -namespace Namespace { - -int test() { -} - -int test2() { -} - -} -} -//!Class template member functions with multiple templates -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h -template -class A { -public: - A(); - /*$*/void test();/*$$*/ -}; - -template -A::A() { -} - -//= -template -class A { -public: - A(); - void test(); -}; - -template -A::A() { -} - -template -inline void A::test() { -} -//!With default parameters -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class Class { -public: - /*$*/void test(int param1, int param2 = 5, int param3 = 10);/*$$*/ -}; - - -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -void Class::test(int param1, int param2, int param3) { -} -//!Static method -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class Class { -public: - /*$*/static void test();/*$$*/ -}; - - -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -void Class::test() { -} -//! Bug 238253 Pointer refence of the return value lost -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class TestClass { -public: - /*$*/int* get(char* val);/*$$*/ -}; - - -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -int* TestClass::get(char* val) { -} -//! Bug 238554 void parameters -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class Test { -public: - /*$*/void doNothing(void);/*$$*/ -}; - - -//@A.cpp -#include "A.h" - -//= -#include "A.h" - -void Test::doNothing(void) { -} -//! Bug 282989 Refactor->Implement method option doesn't qualify the name in the method definition with a fully qualified container class name -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=TestClass.h -infos=1 -//@TestClass.h -#ifndef TESTCLASS_H_ -#define TESTCLASS_H_ - -namespace nspace { - -class TestClass { - void /*$*/testMethod()/*$$*/; -}; - -} - -#endif /* TESTCLASS_H_ */ - -//= -#ifndef TESTCLASS_H_ -#define TESTCLASS_H_ - -namespace nspace { - -class TestClass { - void testMethod(); -}; - -} - -inline void nspace::TestClass::testMethod() { -} - -#endif /* TESTCLASS_H_ */ - -//!Bug 290110 Source-> Implement Method -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -namespace n1 { -namespace n2 { - -class A { -public: - A(); - ~A(); - void testmethod(int x); - -protected: - class B { - public: - void /*$*/testmethod2()/*$$*/; - }; -}; - -} -} - - -#endif /* A_H_ */ -//@A.cpp -#include "A.h" - -namespace n1 { -namespace n2 { - -A::A() { -} - -A::~A() { -} - -} -} - -//= -#include "A.h" - -namespace n1 { -namespace n2 { - -A::A() { -} - -A::~A() { -} - -} -} - -void n1::n2::A::B::testmethod2() { -} -//!Bug 337040 - Insert definition in empty implementation file (.cxx) -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class TestClass { -public: - /*$*/void foo();/*$$*/ -}; - - -//@A.cxx - -//= -void TestClass::foo() { -} -//!Bug 355006 - NPE implementing template function -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -infos=1 -//@A.h - -/*$*/template -void func(T&);/*$$*/ -//= - -template -void func(T&); - -template -inline void func(T&) { -} -//!Bug 363111 - Remove explicit in constructor definition -//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest -//@.config -filename=A.h -//@A.h - -class TestClass { -public: - /*$*/explicit TestClass();/*$$*/ -}; - - -//@A.cpp - -//= -TestClass::TestClass() { -} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java index 1a24b1a7b3a..41c5a494376 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java @@ -21,7 +21,7 @@ import org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefac import org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest; import org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest; -import org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodTestSuite; +import org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.rename.RenameRegressionTests; import org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToogleRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.utils.UtilTestSuite; @@ -39,7 +39,7 @@ public class RefactoringTestSuite extends TestSuite { suite.addTest(ExtractConstantRefactoringTest.suite()); suite.addTest(HideMethodRefactoringTest.suite()); suite.addTest(GenerateGettersAndSettersTest.suite()); - suite.addTest(ImplementMethodTestSuite.suite()); + suite.addTest(ImplementMethodRefactoringTest.suite()); suite.addTest(ExtractLocalVariableRefactoringTest.suite()); suite.addTest(ToogleRefactoringTest.suite()); return suite; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java index d739b058ceb..6979326f7c8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java @@ -39,7 +39,7 @@ public class HideMethodRefactoringTest extends RefactoringTestBase { @Override protected Refactoring createRefactoring() { - return new HideMethodRefactoring(getSelectedFile(), getSelection(), null, getCProject()); + return new HideMethodRefactoring(getSelectedFile(), getSelection(), null, getCProject()); } //A.h diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java index 199b2aa73a2..88835e4ceb2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java @@ -8,46 +8,785 @@ * * Contributors: * Institute for Software - initial API and implementation - * Marc-Andre Laperle * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.implementmethod; -import java.util.Collection; -import java.util.Properties; +import junit.framework.Test; -import org.eclipse.core.resources.IFile; +import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; -import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; +import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestBase; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoring2; import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRefactoring; - + /** - * @author Mirko Stocker + * Tests for Extract Local Variable refactoring. */ -public class ImplementMethodRefactoringTest extends RefactoringTest { +public class ImplementMethodRefactoringTest extends RefactoringTestBase { - public ImplementMethodRefactoringTest(String name, Collection files) { - super(name, files); + public ImplementMethodRefactoringTest() { + super(); + } + + public ImplementMethodRefactoringTest(String name) { + super(name); + } + + public static Test suite() { + return suite(ImplementMethodRefactoringTest.class); } @Override - protected void runTest() throws Throwable { - IFile refFile = project.getFile(fileName); - ICElement element = CoreModel.getDefault().create(refFile); - CRefactoring2 refactoring = new ImplementMethodRefactoring(element, selection, cproject); - executeRefactoring(refactoring); - compareFiles(fileMap); + protected Refactoring createRefactoring() { + return new ImplementMethodRefactoring(getSelectedTranslationUnit(), getSelection(), + getCProject()); } - @Override - protected void configureRefactoring(Properties refactoringProperties) { - finalWarnings = new Integer(refactoringProperties.getProperty("finalWarnings", "0")).intValue(); //$NON-NLS-1$//$NON-NLS-2$ - initialWarnings = Integer.parseInt(refactoringProperties.getProperty("initialWarnings", "0")); //$NON-NLS-1$//$NON-NLS-2$ - finalInfos = Integer.parseInt(refactoringProperties.getProperty("infos", "0")); //$NON-NLS-1$//$NON-NLS-2$ + //A.h + //class X { + //public: + // bool /*$*/a(int = 100)/*$$*/ const; + //}; + //==================== + //class X { + //public: + // bool a(int = 100) const; + //}; + // + //inline bool X::a(int int1) const { + //} + public void testParameterWithDefaultValue() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //class X { + //public: + // bool /*$*/xy(int, int i)/*$$*/ const; + //}; + //==================== + //class X { + //public: + // bool xy(int, int i) const; + //}; + // + //inline bool X::xy(int int1, int i) const { + //} + public void testConstMethod() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //template + //class A { + //public: + // /*$*/void test();/*$$*/ + //}; + //==================== + //template + //class A { + //public: + // void test(); + //}; + // + //template + //inline void A::test() { + //} + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + public void testTestIfTemplateMethodStaysInHeader() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //template + //class A { + //public: + // A(); + // /*$*/void test();/*$$*/ + //}; + // + //template + //A::A() { + //} + //==================== + //template + //class A { + //public: + // A(); + // void test(); + //}; + // + //template + //A::A() { + //} + // + //template + //inline void A::test() { + //} + public void testClassTemplateMemberFunctions() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + // + //class Demo { + // class SubClass { + // /*$*/void test();/*$$*/ + // }; + //}; + // + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + // + //void Demo::SubClass::test() { + //} + public void testMemberClass() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //class A { + //public: + // /*$*/void test();/*$$*/ + //}; + //==================== + //class A { + //public: + // void test(); + //}; + // + //inline void A::test() { + //} + public void testNoImplementationFile() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //class A { + //public: + // /*$*/void test();/*$$*/ + //}; + //==================== + //class A { + //public: + // void test(); + //}; + + //A.cpp + //==================== + //void A::test() { + //} + public void testDeclaredInOtherwiseEmptyClass() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //namespace Namespace { + // + //class ClassInNamespace { + //public: + // int test(); + // /*$*/void test2();/*$$*/ + //}; + // + //} + + //A.cpp + //#include "A.h" + // + //namespace Namespace { + // + //int ClassInNamespace::test() { + // return 5; + //} + // + //} + //==================== + //#include "A.h" + // + //namespace Namespace { + // + //int ClassInNamespace::test() { + // return 5; + //} + // + //void ClassInNamespace::test2() { + //} + // + //} + public void testExistingNamespace() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //class A { + //public: + // A(); + // /*$*/virtual void foo();/*$$*/ + // ~A(); + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //A::A() { + //} + // + //A::~A() { + //} + //==================== + //#include "A.h" + // + //A::A() { + //} + // + //void A::foo() { + //} + // + //A::~A() { + //} + public void testVirtualMethodBetweenCtorAndDtor() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + ///*$*/void function();/*$$*/ + //void function_with_impl(); + + //A.cpp + //void function_with_impl() { + //} + //==================== + //void function() { + //} + // + //void function_with_impl() { + //} + public void testFunctionAtStartOfSourceFile() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //class A { + //public: + // A(); + // /*$*/void foo();/*$$*/ + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //A::A() { + //} + //==================== + //#include "A.h" + // + //A::A() { + //} + // + //void A::foo() { + //} + public void testLastMethodInClass() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //class A { + //public: + // /*$*/void foo() const;/*$$*/ + // A(); + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //A::A() { + //} + //==================== + //#include "A.h" + // + //void A::foo() const { + //} + // + //A::A() { + //} + public void testFirstMethodInClass() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //class A { + //public: + // A(); + // /*$*/int foo();/*$$*/ + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //A::A() { + //} + //==================== + //#include "A.h" + // + //A::A() { + //} + // + //int A::foo() { + //} + public void testWithIntReturnValue() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //class A { + //public: + // A(); + // /*$*/int foo(int param1, int param2);/*$$*/ + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //A::A() { + //} + //==================== + //#include "A.h" + // + //A::A() { + //} + // + //int A::foo(int param1, int param2) { + //} + public void testWithTwoIntParameters() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //class A { + //public: + // A(); + // /*$*/void test();/*$$*/ + //}; + // + //A::A() { + //} + //==================== + //class A { + //public: + // A(); + // void test(); + //}; + // + //A::A() { + //} + // + //inline void A::test() { + //} + public void testDefinedInHeader() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //void function_with_impl(); + ///*$*/void function();/*$$*/ + + //A.cpp + //void function_with_impl() { + //} + //==================== + //void function_with_impl() { + //} + // + //void function() { + //} + public void testFunctionAtEndOfSourceFile() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //namespace Namespace { + // + //class ClassInNamespace { + //public: + // int other_test(); + // /*$*/void test();/*$$*/ + //}; + // + //} + + //A.cpp + //#include "A.h" + //void Namespace::ClassInNamespace::other_test() { + //} + //==================== + //#include "A.h" + //void Namespace::ClassInNamespace::other_test() { + //} + // + //void Namespace::ClassInNamespace::test() { + //} + public void testNamespace() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //namespace OuterSpace { + //namespace Namespace { + // + //int test(); + ///*$*/int test2();/*$$*/ + // + //} + //} + + //A.cpp + //#include "A.h" + //namespace OuterSpace { + // + //int Namespace::test() { + //} + // + //} + //==================== + //#include "A.h" + //namespace OuterSpace { + // + //int Namespace::test() { + //} + // + //int Namespace::test2() { + //} + // + //} + public void testFunctionWithinNamespace() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //namespace OuterSpace { + //namespace Namespace { + // + //int test(); + ///*$*/int test2();/*$$*/ + // + //} + //} + + //A.cpp + //#include "A.h" + //namespace OuterSpace { + //namespace Namespace { + // + //int test() { + //} + // + //} + //} + //==================== + //#include "A.h" + //namespace OuterSpace { + //namespace Namespace { + // + //int test() { + //} + // + //int test2() { + //} + // + //} + //} + public void testFunctionWithinNamespaces() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //template + //class A { + //public: + // A(); + // /*$*/void test();/*$$*/ + //}; + // + //template + //A::A() { + //} + //==================== + //template + //class A { + //public: + // A(); + // void test(); + //}; + // + //template + //A::A() { + //} + // + //template + //inline void A::test() { + //} + public void testMethodOfTemplateClass() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + // + //class Class { + //public: + // /*$*/void test(int param1, int param2 = 5, int param3 = 10);/*$$*/ + //}; + // + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + // + //void Class::test(int param1, int param2, int param3) { + //} + public void testWithDefaultParameters() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + // + //class Class { + //public: + // /*$*/static void test();/*$$*/ + //}; + // + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + // + //void Class::test() { + //} + public void testStaticMethod() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + // + //class TestClass { + //public: + // /*$*/int* get(char* val);/*$$*/ + //}; + // + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + // + //int* TestClass::get(char* val) { + //} + public void testPointerReturnValue_Bug238253() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + // + //class Test { + //public: + // /*$*/void doNothing(void);/*$$*/ + //}; + // + + //A.cpp + //#include "A.h" + //==================== + //#include "A.h" + // + //void Test::doNothing(void) { + //} + public void testVoidParameter_Bug238554() throws Exception { + assertRefactoringSuccess(); + } + + //TestClass.h + //#ifndef TESTCLASS_H_ + //#define TESTCLASS_H_ + // + //namespace nspace { + // + //class TestClass { + // void /*$*/testMethod()/*$$*/; + //}; + // + //} + // + //#endif /* TESTCLASS_H_ */ + //==================== + //#ifndef TESTCLASS_H_ + //#define TESTCLASS_H_ + // + //namespace nspace { + // + //class TestClass { + // void testMethod(); + //}; + // + //} + // + //inline void nspace::TestClass::testMethod() { + //} + // + //#endif /* TESTCLASS_H_ */ + public void testNameQualification_Bug282989() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //namespace n1 { + //namespace n2 { + // + //class A { + //public: + // A(); + // ~A(); + // void testmethod(int x); + // + //protected: + // class B { + // public: + // void /*$*/testmethod2()/*$$*/; + // }; + //}; + // + //} + //} + // + // + //#endif /* A_H_ */ + + //A.cpp + //#include "A.h" + // + //namespace n1 { + //namespace n2 { + // + //A::A() { + //} + // + //A::~A() { + //} + // + //} + //} + //==================== + //#include "A.h" + // + //namespace n1 { + //namespace n2 { + // + //A::A() { + //} + // + //A::~A() { + //} + // + //} + //} + // + //void n1::n2::A::B::testmethod2() { + //} + public void testNestedClass_Bug290110() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + // + //class TestClass { + //public: + // /*$*/void foo();/*$$*/ + //}; + // + + //A.cxx + //==================== + //void TestClass::foo() { + //} + public void testEmptyImplementationFile_Bug337040() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + // + ///*$*/template + //void func(T&);/*$$*/ + //==================== + // + //template + //void func(T&); + // + //template + //inline void func(T&) { + //} + public void testTemplateFunction_Bug355006() throws Exception { + expectedFinalInfos = 1; + assertRefactoringSuccess(); + } + + //A.h + // + //class TestClass { + //public: + // /*$*/explicit TestClass();/*$$*/ + //}; + // + + //A.cpp + //==================== + //TestClass::TestClass() { + //} + public void testExplicitConstructor_Bug363111() throws Exception { + assertRefactoringSuccess(); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodTestSuite.java deleted file mode 100644 index 092d5ba21d2..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodTestSuite.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Google, Inc and others. - * 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: - * Tom Ball - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.implementmethod; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.cdt.ui.tests.refactoring.RefactoringTester; - -/** - * Test suite to run just the Implement Method unit tests. - * - * @author Tom Ball - */ -public class ImplementMethodTestSuite extends TestSuite { - - @SuppressWarnings("nls") - public static Test suite() throws Exception { - TestSuite suite = new ImplementMethodTestSuite(); - suite.addTest(RefactoringTester.suite("ImplementMethodRefactoringTest", - "resources/refactoring/ImplementMethod.rts")); - return suite; - } -}