Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-03-14 10:25:46 +0000
committerAnton Leherbauer2008-03-14 10:25:46 +0000
commitf66dfa5d9af9c89d4022ccbe241d7913acc9ea12 (patch)
tree16b5c8b62657c976f87672cac1590cea34ca87c1 /core/org.eclipse.cdt.core.tests
parent7bce911157b74fac683622df8df63d06edb9d87c (diff)
downloadorg.eclipse.cdt-f66dfa5d9af9c89d4022ccbe241d7913acc9ea12.tar.gz
org.eclipse.cdt-f66dfa5d9af9c89d4022ccbe241d7913acc9ea12.tar.xz
org.eclipse.cdt-f66dfa5d9af9c89d4022ccbe241d7913acc9ea12.zip
Fix for 222398: [Model Builder] problem with inlined qualified member declaration
and fix handling of multiple namespace definitions
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java1
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java70
-rw-r--r--core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/cmodel/CModelBuilderTest.cpp12
4 files changed, 87 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
index ea99f47ce41..a882db00d71 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AllCoreTests.java
@@ -58,6 +58,7 @@ public class AllCoreTests {
suite.addTest(PathSettingsContainerTests.suite());
suite.addTest(ASTCacheTests.suite());
suite.addTest(AsmModelBuilderTest.suite());
+ suite.addTest(CModelBuilderBugsTest.suite());
return suite;
}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java
new file mode 100644
index 00000000000..2180e1f9447
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Anton Leherbauer (Wind River Systems) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.core.model.tests;
+
+import junit.framework.Test;
+
+import org.eclipse.cdt.core.dom.IPDOMManager;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.model.INamespace;
+import org.eclipse.cdt.core.model.IStructure;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.testplugin.CProjectHelper;
+import org.eclipse.cdt.core.testplugin.CTestPlugin;
+import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
+
+/**
+ * Tests for C model builder bugs.
+ */
+public class CModelBuilderBugsTest extends BaseTestCase {
+
+ public static Test suite() {
+ return suite(CModelBuilderBugsTest.class, "_");
+ }
+
+ private ICProject fCProject;
+ private ITranslationUnit fTU;
+
+ public CModelBuilderBugsTest(String name) {
+ super(name);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ fCProject= CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER);
+ assertNotNull(fCProject);
+ CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/cmodel");
+ fTU= (ITranslationUnit) CProjectHelper.findElement(fCProject, "CModelBuilderTest.cpp");
+ assertNotNull(fTU);
+ }
+
+ protected void tearDown() throws Exception {
+ CProjectHelper.delete(fCProject);
+ super.tearDown();
+ }
+
+ public void testModelBuilderBug222398() throws Exception {
+ IStructure clazz= (IStructure) fTU.getElement("Test");
+ assertNotNull(clazz);
+ ICElement[] methods= clazz.getChildren();
+ assertEquals(2, methods.length);
+ assertEquals("inlined", methods[0].getElementName());
+ assertEquals("decl", methods[1].getElementName());
+
+ INamespace ns= (INamespace) fTU.getElement("nsTest");
+ ICElement[] functions= ns.getChildren();
+ assertEquals(2, functions.length);
+ assertEquals("inlined", functions[0].getElementName());
+ assertEquals("decl", functions[1].getElementName());
+ }
+
+}
diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
index be8a75385b0..1685b8b4f20 100644
--- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Anton Leherbauer (Wind River Systems)
*******************************************************************************/
/*
* Created on Jun 17, 2003
@@ -153,7 +154,7 @@ public class ITemplateTests extends IntegratedCModelTest {
// actually, none of the two are function templates, but method templates
String[] myExpectedValues = {
// "nonVector<T>::first",
- "Foo::fum",
+// "Foo::fum",
};
assertEquals(myExpectedValues.length, arrayElements.size());
// This test is no correct there is no guaranty on the order
@@ -169,11 +170,9 @@ public class ITemplateTests extends IntegratedCModelTest {
{
// Check the template method
List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD);
- // actually, both of the two are method templates, but Foo is not resolved
- // to a cpp class
String[] myExpectedValues = {
"nonVector<T>::first",
-// "Foo::fum",
+ "Foo::fum",
};
assertEquals(myExpectedValues.length, arrayElements.size());
// This test is no correct there is no guaranty on the order
diff --git a/core/org.eclipse.cdt.core.tests/resources/cmodel/CModelBuilderTest.cpp b/core/org.eclipse.cdt.core.tests/resources/cmodel/CModelBuilderTest.cpp
new file mode 100644
index 00000000000..35a7f1f8086
--- /dev/null
+++ b/core/org.eclipse.cdt.core.tests/resources/cmodel/CModelBuilderTest.cpp
@@ -0,0 +1,12 @@
+class Test {
+ void Test::inlined() {}; // wrong label in outline: Test::inlined(): void
+ void Test::decl(); // label in outline (ok): decl(): void
+};
+namespace nsTest {
+ void nsTest::inlined() {}; // wrong label in outline: nsTest::inlined(): void
+ void nsTest::decl(); // label in outline (ok): decl(): void
+}
+namespace nsTest {
+ void nsTest::inlined2() {}; // wrong label in outline: nsTest::inlined(): void
+ void nsTest::decl2(); // label in outline (ok): decl(): void
+}

Back to the top