Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] CCompletionProposalsTest modification


Core Tests:
        Modified CCompletionProposalsTest to complete on a body file that includes a header file.

Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group


Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.71
diff -u -r1.71 ChangeLog
--- ChangeLog	28 Aug 2003 20:14:11 -0000	1.71
+++ ChangeLog	2 Sep 2003 15:04:45 -0000
@@ -1,3 +1,7 @@
+2003-09-02 Hoda Amer
+	Modified CCompletionProposalsTest to complete on a body file 
+	that includes a header file.
+	
 2003-08-28 Andrew Niefer
 	Modified BaseSearchTest.setup to properly include the "include.h" file
 
Index: model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java,v
retrieving revision 1.1
diff -u -r1.1 CompletionProposalsTest.java
--- model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java	12 Aug 2003 20:19:47 -0000	1.1
+++ model/org/eclipse/cdt/core/codeassist/tests/CompletionProposalsTest.java	2 Sep 2003 15:04:45 -0000
@@ -18,6 +18,7 @@
 import org.eclipse.cdt.core.CCProjectNature;
 import org.eclipse.cdt.core.CCorePlugin;
 import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.ICElement;
 import org.eclipse.cdt.core.model.ICProject;
 import org.eclipse.cdt.internal.core.model.TranslationUnit;
 import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
@@ -43,6 +44,7 @@
 	private final static long MAGIC_NUMBER = 1000;
 	private ICProject fCProject;
 	private IFile headerFile;
+	private IFile bodyFile;
 	private NullProgressMonitor monitor;
 		
 	public static Test suite() {
@@ -60,11 +62,14 @@
 		String pluginRoot=org.eclipse.core.runtime.Platform.getPlugin("org.eclipse.cdt.core.tests").find(new Path("/")).getFile();
 	
 		fCProject= CProjectHelper.createCProject("TestProject1", "bin");
-		headerFile = fCProject.getProject().getFile("CompletionProposalsTest.h");
-		if (!headerFile.exists()) {
+		bodyFile = fCProject.getProject().getFile("CompletionProposalsTestStart.cpp");
+		headerFile = fCProject.getProject().getFile("CompletionProposalsTestStart.h");
+		if ((!headerFile.exists()) || (!bodyFile.exists())) {
 			try{
-				FileInputStream fileIn = new FileInputStream(pluginRoot+ "resources/cfiles/CompletionProposalsTestStart.h"); 
-				headerFile.create(fileIn,false, monitor);        
+				FileInputStream bodyFileIn = new FileInputStream(pluginRoot+ "resources/cfiles/CompletionProposalsTestStart.cpp"); 
+				bodyFile.create(bodyFileIn,false, monitor);        
+				FileInputStream headerFileIn = new FileInputStream(pluginRoot+ "resources/cfiles/CompletionProposalsTestStart.h"); 
+				headerFile.create(headerFileIn,false, monitor);        
 			} catch (CoreException e) {
 				e.printStackTrace();
 			}
@@ -97,9 +102,10 @@
 			
 	public void testCompletionProposals(){
 		try{
-			TranslationUnit tu = new TranslationUnit(fCProject, headerFile);
+			TranslationUnit headerTu = new TranslationUnit(fCProject, headerFile);
+			TranslationUnit tu = new TranslationUnit(fCProject, bodyFile);
 			Document document = new Document(tu.getBuffer().getContents());
-			int pos = 399;
+			int pos = 255;
 			int length = 0;
 			CCompletionProcessor completionProcessor = new CCompletionProcessor(null);
 			ICompletionProposal[] results = completionProcessor.evalProposals(document, pos, length, tu);
@@ -108,36 +114,30 @@
 			} catch (InterruptedException e1) {
 				fail( "Bogdan's hack did not suffice");
 			}
-			assertEquals(results.length, 9);
+			assertEquals(results.length, 7);
 			for (int i = 0; i<results.length; i++){
 				ICompletionProposal proposal = results[i];
 				String displayString = proposal.getDisplayString();
 				switch(i){
 					case 0:
-						assertEquals(displayString, "anotherField");
+						assertEquals(displayString, "aVariable");
 					break;	
 					case 1:
-						assertEquals(displayString, "aVariable");
+						assertEquals(displayString, "aFunction() void");
 					break;	
 					case 2:
-						assertEquals(displayString, "anotherMethod(int, char) void");
-					break;	
-					case 3:
-						assertEquals(displayString, "aFunction(char, int) void");
-					break;	
-					case 4:
 						assertEquals(displayString, "aClass");
 					break;	
-					case 5:
+					case 3:
 						assertEquals(displayString, "anotherClass");
 					break;	
-					case 6:
+					case 4:
 						assertEquals(displayString, "aStruct");
 					break;	
-					case 7:
+					case 5:
 						assertEquals(displayString, "aMacro");
 					break;	
-					case 8:
+					case 6:
 						assertEquals(displayString, "anEnumeration");
 					break;	
 				}
Index: resources/cfiles/CompletionProposalsTestStart.cpp
===================================================================
RCS file: resources/cfiles/CompletionProposalsTestStart.cpp
diff -N resources/cfiles/CompletionProposalsTestStart.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ resources/cfiles/CompletionProposalsTestStart.cpp	2 Sep 2003 15:04:45 -0000
@@ -0,0 +1,20 @@
+#include "CompletionProposalsTestStart.h"
+
+#define aMacro(x) x+1
+
+int aVariable = 0;
+void aFunction();
+
+enum anEnumeration {
+	first,
+	second, 
+	third 
+};
+
+struct aStruct{
+	int aStructField = 0;
+};
+
+void anotherClass::anotherMethod(){
+  a
+};
\ No newline at end of file
Index: resources/cfiles/CompletionProposalsTestStart.h
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/cfiles/CompletionProposalsTestStart.h,v
retrieving revision 1.1
diff -u -r1.1 CompletionProposalsTestStart.h
--- resources/cfiles/CompletionProposalsTestStart.h	12 Aug 2003 20:19:47 -0000	1.1
+++ resources/cfiles/CompletionProposalsTestStart.h	2 Sep 2003 15:04:45 -0000
@@ -1,32 +1,11 @@
-#define aMacro(x) x+1
-
-int aVariable = 0;
-void aFunction(char P1, int P2){
-	int f1 = 0;
-}
-
-enum anEnumeration {
-	first,
-	second, 
-	third 
-};
-
-struct aStruct{
-	int aStructField = 0;
-};
-
 class aClass {
 public:
 	int aField;
-	int aMethod(int P1, char P2){
-		return P1 + P2;
-	}
+	int aMethod();
 };
 
 class anotherClass {
 public:
 	int anotherField = 0;
-	void anotherMethod(int P1, char P2){
-		a
-	}
-};
\ No newline at end of file
+	void anotherMethod();
+};

Back to the top