1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Tests for bug 249177: ExtractFunction specifies void for constant types

https://bugs.eclipse.org/bugs/show_bug.cgi?id=249177 Patch by Tom Ball
This commit is contained in:
Emanuel Graf 2008-10-27 10:01:41 +00:00
parent 6f602ad621
commit 7d3fbffa1a

View file

@ -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();
}