View Javadoc

    1   package net.sourceforge.pmd.dfa;
    2
    3   import static org.junit.Assert.assertEquals;
    4   import net.sourceforge.pmd.lang.dfa.VariableAccess;
    5
    6   import org.junit.Test;
    7   public class VariableAccessTest {
    8
    9       @Test
    10      public void testGetVariableName() {
    11          VariableAccess va = new VariableAccess(VariableAccess.DEFINITION, "foo.bar");
    12          assertEquals("foo", va.getVariableName());
    13          va = new VariableAccess(VariableAccess.DEFINITION, ".foobar");
    14          assertEquals("", va.getVariableName());
    15          va = new VariableAccess(VariableAccess.DEFINITION, "foobar.");
    16          assertEquals("foobar", va.getVariableName());
    17          va = new VariableAccess(VariableAccess.DEFINITION, "foobar");
    18          assertEquals("foobar", va.getVariableName());
    19      }
    20
    21      public static junit.framework.Test suite() {
    22          return new junit.framework.JUnit4TestAdapter(VariableAccessTest.class);
    23      }
    24  }