1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

Testcases for content assist, bug 180885.

This commit is contained in:
Markus Schorn 2008-04-21 10:54:03 +00:00
parent 95763b595e
commit 0b8ddc570e
2 changed files with 49 additions and 7 deletions

View file

@ -165,6 +165,7 @@ public class CompletionTests extends AbstractContentAssistTest {
/* /*
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractCompletionTest#setUpProjectContent(org.eclipse.core.resources.IProject) * @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractCompletionTest#setUpProjectContent(org.eclipse.core.resources.IProject)
*/ */
@Override
protected IFile setUpProjectContent(IProject project) throws Exception { protected IFile setUpProjectContent(IProject project) throws Exception {
fProject= project; fProject= project;
String headerContent= readTaggedComment(HEADER_FILE_NAME); String headerContent= readTaggedComment(HEADER_FILE_NAME);
@ -180,6 +181,7 @@ public class CompletionTests extends AbstractContentAssistTest {
/* /*
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest#doCheckExtraResults() * @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest#doCheckExtraResults()
*/ */
@Override
protected boolean doCheckExtraResults() { protected boolean doCheckExtraResults() {
return fCheckExtraResults; return fCheckExtraResults;
} }
@ -1010,11 +1012,11 @@ public class CompletionTests extends AbstractContentAssistTest {
public static void deleteDir(File dir) { public static void deleteDir(File dir) {
File[] files = dir.listFiles(); File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) { for (File file : files) {
if (files[i].isDirectory()) { if (file.isDirectory()) {
deleteDir(files[i]); deleteDir(file);
} else { } else {
files[i].delete(); file.delete();
} }
} }
dir.delete(); dir.delete();
@ -1022,8 +1024,8 @@ public class CompletionTests extends AbstractContentAssistTest {
private static void createIncludeFiles(File dir, String[] files) throws IOException { private static void createIncludeFiles(File dir, String[] files) throws IOException {
Set<String> includeDirs= new HashSet<String>(); Set<String> includeDirs= new HashSet<String>();
for (int i = 0; i < files.length; i++) { for (String file2 : files) {
File file = new File(dir, files[i]); File file = new File(dir, file2);
final File parentFile= file.getParentFile(); final File parentFile= file.getParentFile();
if (parentFile.getName().startsWith("sub")) { if (parentFile.getName().startsWith("sub")) {
if (!parentFile.exists()) { if (!parentFile.exists()) {
@ -1034,7 +1036,27 @@ public class CompletionTests extends AbstractContentAssistTest {
} }
file.createNewFile(); file.createNewFile();
} }
TestScannerProvider.sIncludes= (String[]) includeDirs.toArray(new String[includeDirs.size()]); TestScannerProvider.sIncludes= includeDirs.toArray(new String[includeDirs.size()]);
} }
// void test() {
// int local;
// switch(loc/*cursor*/
public void testSwitchStatement() throws Exception {
final String[] expected= {
"local"
};
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
}
// void test() {
// int local;
// while(loc/*cursor*/
public void testWhileStatement() throws Exception {
final String[] expected= {
"local"
};
assertCompletionResults(fCursorOffset, expected, AbstractContentAssistTest.COMPARE_REP_STRINGS);
}
} }

View file

@ -846,5 +846,25 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
}; };
assertCompletionResults(expected); assertCompletionResults(expected);
} }
// void test() {
// int local;
// switch(loc/*cursor*/
public void testSwitchStatement() throws Exception {
final String[] expected= {
"local"
};
assertCompletionResults(expected);
}
// void test() {
// int local;
// while(loc/*cursor*/
public void testWhileStatement() throws Exception {
final String[] expected= {
"local"
};
assertCompletionResults(expected);
}
} }