summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Weinstein2013-03-11 16:36:31 (EDT)
committer Sergey Prigogin2013-03-12 18:29:23 (EDT)
commite063f00b674db979d5e634a9dda4f631b3c0614b (patch)
treecc6bd70ae2ce8e693398da2663b433f0a6e98602
parent4d120934328af8d3e736c824ceb929f6549fd245 (diff)
downloadorg.eclipse.cdt-e063f00b674db979d5e634a9dda4f631b3c0614b.zip
org.eclipse.cdt-e063f00b674db979d5e634a9dda4f631b3c0614b.tar.gz
org.eclipse.cdt-e063f00b674db979d5e634a9dda4f631b3c0614b.tar.bz2
Bug 240692 -- Fix rename for templatesrefs/changes/64/11064/4
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>
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java106
1 files changed, 66 insertions, 40 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java
index 1adde37..fa30925 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java
@@ -24,44 +24,70 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus;
*/
public class RenameTemplatesTests extends RenameTests {
- public RenameTemplatesTests(String name) {
- super(name);
- }
-
- 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 RenameTemplatesTests(String name) {
+ super(name);
+ }
+
+ 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"));
+ }
+ 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"));
+ }
}