1 /** 2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html 3 */ 4 package test.net.sourceforge.pmd.symboltable; 5 6 import static org.junit.Assert.assertEquals; 7 import net.sourceforge.pmd.ast.ASTVariableDeclaratorId; 8 import net.sourceforge.pmd.symboltable.ImageFinderFunction; 9 import net.sourceforge.pmd.symboltable.NameDeclaration; 10 import net.sourceforge.pmd.symboltable.VariableNameDeclaration; 11 12 import org.junit.Test; 13 14 import java.util.ArrayList; 15 import java.util.List; 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(ImageFinderFunctionTest.class); 43 } 44 }