01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package test.net.sourceforge.pmd.symboltable;
04:
05: import static org.junit.Assert.assertEquals;
06: import net.sourceforge.pmd.ast.ASTVariableDeclaratorId;
07: import net.sourceforge.pmd.symboltable.ImageFinderFunction;
08: import net.sourceforge.pmd.symboltable.NameDeclaration;
09: import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
10:
11: import org.junit.Test;
12:
13: import java.util.ArrayList;
14: import java.util.List;
15:
16: public class ImageFinderFunctionTest {
17:
18: @Test
19: public void testSingleImage() {
20: ImageFinderFunction f = new ImageFinderFunction("foo");
21: ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
22: node.setImage("foo");
23: NameDeclaration decl = new VariableNameDeclaration(node);
24: f.applyTo(decl);
25: assertEquals(decl, f.getDecl());
26: }
27:
28: @Test
29: public void testSeveralImages() {
30: List<String> imgs = new ArrayList<String>();
31: imgs.add("Foo.foo");
32: imgs.add("foo");
33: ImageFinderFunction f = new ImageFinderFunction(imgs);
34: ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
35: node.setImage("foo");
36: NameDeclaration decl = new VariableNameDeclaration(node);
37: f.applyTo(decl);
38: assertEquals(decl, f.getDecl());
39: }
40:
41: public static junit.framework.Test suite() {
42: return new junit.framework.JUnit4TestAdapter(
43: ImageFinderFunctionTest.class);
44: }
45: }
|