mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 240692 -- Fix rename for templates
Just a failing test, so far. Change-Id: Idb923862614ff2f1b7736495d8a2d8967e278de7 Reviewed-on: https://git.eclipse.org/r/11064 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
4d12093432
commit
e063f00b67
1 changed files with 64 additions and 38 deletions
|
@ -24,44 +24,70 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
|||
*/
|
||||
public class RenameTemplatesTests extends RenameTests {
|
||||
|
||||
public RenameTemplatesTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
public RenameTemplatesTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite(){
|
||||
return suite(true);
|
||||
}
|
||||
public static Test suite() {
|
||||
return suite(true);
|
||||
}
|
||||
|
||||
public static Test suite( boolean cleanup ) {
|
||||
TestSuite suite = new TestSuite(RenameTemplatesTests.class);
|
||||
if (cleanup) {
|
||||
suite.addTest( new RefactoringTests("cleanupProject") ); //$NON-NLS-1$
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void testClassTemplate() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("template <class Type> \n"); //$NON-NLS-1$
|
||||
writer.write("class Array { \n"); //$NON-NLS-1$
|
||||
writer.write("public: \n"); //$NON-NLS-1$
|
||||
writer.write(" Array(unsigned sz) {} \n"); //$NON-NLS-1$
|
||||
writer.write(" ~Array(){} \n"); //$NON-NLS-1$
|
||||
writer.write(" Type& operator[] (unsigned idx); \n"); //$NON-NLS-1$
|
||||
writer.write("}; \n"); //$NON-NLS-1$
|
||||
writer.write("template <class Type> \n"); //$NON-NLS-1$
|
||||
writer.write("inline Type& Array<Type>::operator[] (unsigned index) {\n"); //$NON-NLS-1$
|
||||
writer.write(" return 1; \n"); //$NON-NLS-1$
|
||||
writer.write("}; \n"); //$NON-NLS-1$
|
||||
String contents = writer.toString();
|
||||
IFile cpp= importFile("test.cpp", contents ); //$NON-NLS-1$
|
||||
|
||||
int offset1= contents.indexOf("Array"); //$NON-NLS-1$
|
||||
|
||||
RefactoringStatus stat= checkConditions(cpp, offset1, "WELT"); //$NON-NLS-1$
|
||||
assertRefactoringOk(stat);
|
||||
|
||||
Change ch= getRefactorChanges(cpp, offset1, "WELT"); //$NON-NLS-1$
|
||||
assertTotalChanges(4, ch);
|
||||
}
|
||||
public static Test suite(boolean cleanup) {
|
||||
TestSuite suite = new TestSuite(RenameTemplatesTests.class);
|
||||
if (cleanup) {
|
||||
suite.addTest(new RefactoringTests("cleanupProject"));
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void testClassTemplate() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("template <class Type> \n");
|
||||
writer.write("class Array { \n");
|
||||
writer.write("public: \n");
|
||||
writer.write(" Array(unsigned sz) {} \n");
|
||||
writer.write(" ~Array(){} \n");
|
||||
writer.write(" Type& operator[] (unsigned idx); \n");
|
||||
writer.write("}; \n");
|
||||
writer.write("template <class Type> \n");
|
||||
writer.write("inline Type& Array<Type>::operator[] (unsigned index) {\n");
|
||||
writer.write(" return 1; \n");
|
||||
writer.write("}; \n");
|
||||
String contents = writer.toString();
|
||||
IFile cpp = importFile("test.cpp", contents);
|
||||
|
||||
int offset1 = contents.indexOf("Array");
|
||||
|
||||
RefactoringStatus stat = checkConditions(cpp, offset1, "WELT");
|
||||
assertRefactoringOk(stat);
|
||||
|
||||
Change ch = getRefactorChanges(cpp, offset1, "WELT");
|
||||
assertTotalChanges(4, ch);
|
||||
}
|
||||
|
||||
public void _testRenameSpecializations_bug240692() throws Exception {
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
writer.write("template <class T>\n");
|
||||
writer.write("class CSome {\n");
|
||||
writer.write("public:\n");
|
||||
writer.write(" void Foo() {};\n");
|
||||
writer.write("};\n");
|
||||
|
||||
writer.write("int main ()\n");
|
||||
writer.write("{\n");
|
||||
writer.write(" CSome <int> A;\n");
|
||||
writer.write(" A.Foo();\n");
|
||||
writer.write(" return 0;\n");
|
||||
writer.write("}\n");
|
||||
String contents = writer.toString();
|
||||
IFile cpp = importFile("test.cpp", contents);
|
||||
|
||||
int offset1 = contents.indexOf("Foo");
|
||||
|
||||
RefactoringStatus stat = checkConditions(cpp, offset1, "Baz");
|
||||
assertRefactoringOk(stat);
|
||||
|
||||
assertTotalChanges(2, getRefactorChanges(cpp, offset1, "Baz"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue