mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix JUnit tests
This commit is contained in:
parent
518b582cd0
commit
36b57b7212
4 changed files with 24 additions and 21 deletions
|
@ -77,13 +77,15 @@ public class BasicCEditorTest extends BaseUITestCase {
|
|||
private TestDocListener fDocListener= new TestDocListener();
|
||||
|
||||
public static Test suite() {
|
||||
return new TestSuite(BasicCEditorTest.class);
|
||||
return new TestSuite(BasicCEditorTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown () throws Exception {
|
||||
EditorTestHelper.closeEditor(fEditor);
|
||||
if (fCProject != null)
|
||||
|
@ -185,6 +187,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
|||
// return 0;
|
||||
// }
|
||||
//}
|
||||
//
|
||||
public void testEditNewTranslationUnit() throws Exception {
|
||||
fCProject= EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false);
|
||||
IFile newFile= createFile(fCProject.getProject(), "Point.cpp", "");
|
||||
|
@ -222,7 +225,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
|||
setUpEditor(newFile);
|
||||
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
||||
content= fDocument.get();
|
||||
content= fDocument.get().trim();
|
||||
assertEquals("Save failed", newContent, content);
|
||||
// check reconciler
|
||||
ITranslationUnit tUnit= (ITranslationUnit)fEditor.getInputCElement();
|
||||
|
@ -352,6 +355,7 @@ public class BasicCEditorTest extends BaseUITestCase {
|
|||
fAccessor.invoke("handleKeyDown", new Object[] {event});
|
||||
|
||||
new DisplayHelper() {
|
||||
@Override
|
||||
protected boolean condition() {
|
||||
return fDocListener.fDocChanged;
|
||||
}
|
||||
|
|
|
@ -75,13 +75,13 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
//
|
||||
//extern C1* gfC1();
|
||||
//C2* gfC2();
|
||||
//
|
||||
//enum E1 {e11, e12};
|
||||
//
|
||||
//enum E1 {e11, e12};
|
||||
//
|
||||
//class C1 {
|
||||
//public:
|
||||
// enum E2 {e21, e22};
|
||||
//
|
||||
// enum E2 {e21, e22};
|
||||
//
|
||||
// C1* fMySelf;
|
||||
// void iam1();
|
||||
//
|
||||
|
@ -117,7 +117,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
//
|
||||
// C3* m123();
|
||||
// C3* m13();
|
||||
//
|
||||
//
|
||||
// template<typename T> T tConvert();
|
||||
//private:
|
||||
// void m3private();
|
||||
|
@ -395,14 +395,14 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
final String[] expected= {
|
||||
"T1", "T2", "T3", "TClass"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||
}
|
||||
|
||||
//namespace ns {void nsfunc(){C/*cursor*/
|
||||
public void testTypes_NamespaceScope() throws Exception {
|
||||
final String[] expected= {
|
||||
"C1", "C2", "C3", "CNS"
|
||||
"C1", "C2", "C3", "CNS"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||
|
@ -422,7 +422,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
final String[] expected= {
|
||||
"e11", "e12", "E1"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
final String[] expected= {
|
||||
"e11", "e12", "e21", "e22", "E1", "E2"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
//#i/*cursor*/
|
||||
public void testCompletePreprocessorDirective() throws Exception {
|
||||
final String[] expected= {
|
||||
"#if ", "#ifdef ", "#ifndef ", "#include "
|
||||
"#if", "#ifdef", "#ifndef", "#include"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected,
|
||||
AbstractContentAssistTest.COMPARE_ID_STRINGS);
|
||||
|
@ -830,7 +830,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
// } my_struct;
|
||||
//
|
||||
// void func(my_struct s);
|
||||
//
|
||||
//
|
||||
// void test() {
|
||||
// fun/*cursor*/
|
||||
public void testFunctionWithTypedefToAnonymousType_bug192787() throws Exception {
|
||||
|
@ -847,7 +847,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
public void testBindingsWithoutDeclaration() throws Exception {
|
||||
// gC1all, gStruct, gnsClass, gnsStruct: fix for 214146, type from a source file is not proposed.
|
||||
final String[] expected= {
|
||||
"gC1", "gC2", "gfC1()", "gfC2()",
|
||||
"gC1", "gC2", "gfC1()", "gfC2()",
|
||||
"gns::", "gnsFunc()", "gnsTemp",
|
||||
"gFunc()", "gTemp"
|
||||
};
|
||||
|
|
|
@ -17,7 +17,6 @@ import junit.framework.Assert;
|
|||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
|
@ -89,6 +88,7 @@ public class DocCommentHighlightingTest extends BaseUITestCase {
|
|||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fCProject= EditorTestHelper.createCProject(PROJECT, LINKED_FOLDER);
|
||||
|
@ -97,10 +97,10 @@ public class DocCommentHighlightingTest extends BaseUITestCase {
|
|||
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
|
||||
// source positions depend on Windows line separator
|
||||
adjustLineSeparator(fSourceViewer.getDocument(), "\r\n");
|
||||
fEditor.doSave(new NullProgressMonitor());
|
||||
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown () throws Exception {
|
||||
EditorTestHelper.closeAllEditors();
|
||||
|
||||
|
|
|
@ -83,9 +83,8 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
|||
Image image = imagedesc != null ? CUIPlugin.getImageDescriptorRegistry().get(imagedesc) : null;
|
||||
|
||||
for(String keyword : languageKeywords.getPreprocessorKeywords()) {
|
||||
keyword = keyword + ' ';
|
||||
String repString = keyword;
|
||||
if (repString.startsWith(prefix) && keyword.length() > prefixLength) {
|
||||
if (keyword.startsWith(prefix) && keyword.length() > prefixLength) {
|
||||
String repString = keyword + ' ';
|
||||
int repLength = prefixLength;
|
||||
int repOffset = context.getInvocationOffset() - repLength;
|
||||
if (prefix.charAt(0) == '#') {
|
||||
|
@ -99,7 +98,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
|||
proposals.add(new CCompletionProposal(repString, repOffset,
|
||||
repLength, image, keyword, relevance, context.getViewer()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isValidContext(completionNode))
|
||||
return Collections.emptyList();
|
||||
|
@ -150,7 +149,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
|
|||
* Test whether the invocation offset is inside or before the preprocessor directive keyword.
|
||||
*
|
||||
* @param context the invocation context
|
||||
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
|
||||
* @return <code>true</code> if the invocation offset is inside or before the directive keyword
|
||||
*/
|
||||
private boolean inPreprocessorKeyword(CContentAssistInvocationContext context) {
|
||||
IDocument doc = context.getDocument();
|
||||
|
|
Loading…
Add table
Reference in a new issue