diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts index 30cc977b6a9..65983150b76 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ExtractExpression.rts @@ -686,3 +686,261 @@ void Test::test() bool b = invalid(); } +//!Extract string constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=greeting + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + wchar_t greeting(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + char* hi = /*$*/"hello"/*$$*/; +} + +//= +#include "test.h" + +wchar_t Test::greeting() +{ + return "hello"; +} + +void Test::test() +{ + char* hi = greeting(); +} + +//!Extract int constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=size + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + int size(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + int i = /*$*/42/*$$*/; +} + +//= +#include "test.h" + +int Test::size() +{ + return 42; +} + +void Test::test() +{ + int i = size(); +} + +//!Extract float constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=certainty + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + float certainty(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + float f = /*$*/0.42/*$$*/; +} + +//= +#include "test.h" + +float Test::certainty() +{ + return 0.42; +} + +void Test::test() +{ + float f = certainty(); +} + +//!Extract char constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=newline + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + char newline(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + char nl = /*$*/'\n'/*$$*/; +} + +//= +#include "test.h" + +char Test::newline() +{ + return '\n'; +} + +void Test::test() +{ + char nl = newline(); +} + +//!Extract boolean true constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=valid + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + bool valid(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + bool b = /*$*/true/*$$*/; +} + +//= +#include "test.h" + +bool Test::valid() +{ + return true; +} + +void Test::test() +{ + bool b = valid(); +} + +//!Extract boolean false constant +//#org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest + +//@.config +filename=test.cpp +methodname=invalid + +//@test.h +class Test +{ + void test(); +}; + + +//= +class Test +{ + void test(); + bool invalid(); +}; + + +//@test.cpp +#include "test.h" + +void Test::test() +{ + bool b = /*$*/false/*$$*/; +} + +//= +#include "test.h" + +bool Test::invalid() +{ + return false; +} + +void Test::test() +{ + bool b = invalid(); +} +