1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

Bug 336123 - Test case by Marc-Andre Laperle

This commit is contained in:
Sergey Prigogin 2011-02-05 02:50:43 +00:00
parent 1bd981230f
commit 6addb930f2
3 changed files with 75 additions and 3 deletions

View file

@ -0,0 +1,20 @@
//!Find function definition
//#org.eclipse.cdt.ui.tests.refactoring.utils.DefinitionFinderTest
//@.config
filename=A.h
//@A.h
#ifndef A_H_
#define A_H_
void foo();
#endif /*A_H_*/
//@A.cpp
#include "A.h"
void foo()
{
}

View file

@ -0,0 +1,52 @@
/*******************************************************************************
* Copyright (c) 2011 Marc-Andre Laperle 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:
* Marc-Andre Laperle - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.utils;
import java.util.Collection;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile;
import org.eclipse.cdt.internal.ui.refactoring.utils.DefinitionFinder2;
public class DefinitionFinderTest extends RefactoringTest {
public DefinitionFinderTest(String name, Collection<TestSourceFile> files) {
super(name, files);
}
@Override
protected void configureRefactoring(Properties refactoringProperties) {
}
@Override
protected void runTest() throws Throwable {
IFile file = project.getFile(fileName);
ICElement element = CCorePlugin.getDefault().getCoreModel().create(file);
if (element instanceof ITranslationUnit) {
IASTTranslationUnit unit = astCache.getAST((ITranslationUnit) element, null);
for (IASTDeclaration declaration : unit.getDeclarations()) {
if (declaration instanceof IASTSimpleDeclaration) {
assertNotNull(DefinitionFinder2.getDefinition((IASTSimpleDeclaration) declaration, astCache));
}
}
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.utils;
@ -18,7 +18,6 @@ import org.eclipse.cdt.ui.tests.refactoring.RefactoringTester;
/**
* @author Thomas Corbat
*
*/
public class UtilTestSuite extends TestSuite {
@ -26,6 +25,7 @@ public class UtilTestSuite extends TestSuite {
UtilTestSuite suite = new UtilTestSuite();
suite.addTest(IdentifierHelperTest.suite());
suite.addTest(RefactoringTester.suite("TranslationUnitHelperTest", "resources/refactoring/TranslationunitHelper.rts")); //$NON-NLS-1$ //$NON-NLS-2$
suite.addTest(RefactoringTester.suite("DefinitionFinderTest", "resources/refactoring/DefinitionFinder.rts")); //$NON-NLS-1$ //$NON-NLS-2$
suite.addTestSuite(PseudoNameGeneratorTest.class);
return suite;
}