*** empty log message ***

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@565 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-31 14:41:06 +00:00
parent eaa86d2997
commit 4d0b843d65
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,48 @@
/*
* User: tom
* Date: Jul 31, 2002
* Time: 10:24:58 AM
*/
package test.net.sourceforge.pmd.cpd;
import junit.framework.TestCase;
import net.sourceforge.pmd.cpd.TokenSet;
import net.sourceforge.pmd.cpd.Token;
import net.sourceforge.pmd.cpd.Tile;
import net.sourceforge.pmd.cpd.Occurrence;
public class TokenSetTest extends TestCase{
public TokenSetTest(String name) {
super(name);
}
public void testBasic() {
TokenSet ts = new TokenSet("foo");
assertEquals("foo", ts.getID());
}
public void testAdd() {
Token tok = new Token('l', 9, "foo");
TokenSet ts = new TokenSet("foo");
ts.add(tok);
assertEquals(tok, ts.get(0));
assertTrue(ts.iterator().hasNext());
}
public void testHasTokenAfter() {
TokenSet ts = new TokenSet("foo");
Token tok = new Token('h', 0, "foo");
ts.add(tok);
Token tok1 = new Token('e', 1, "foo");
ts.add(tok1);
Token tok3 = new Token('l', 2, "foo");
ts.add(tok3);
Token tok4 = new Token('l', 3, "foo");
ts.add(tok4);
Token tok5 = new Token('o', 4, "foo");
ts.add(tok5);
assertTrue(ts.hasTokenAfter(new Tile(tok), new Occurrence("foo", tok)));
}
}

View File

@ -0,0 +1,28 @@
/*
* User: tom
* Date: Jul 31, 2002
* Time: 10:36:22 AM
*/
package test.net.sourceforge.pmd.cpd;
import junit.framework.TestCase;
import net.sourceforge.pmd.cpd.TokenSets;
import net.sourceforge.pmd.cpd.TokenSet;
import net.sourceforge.pmd.cpd.Occurrence;
import net.sourceforge.pmd.cpd.Token;
public class TokenSetsTest extends TestCase {
public TokenSetsTest(String name) {
super(name);
}
public void testBasic() {
Token tok = new Token('h', 0, "foo");
TokenSets tss = new TokenSets();
TokenSet ts = new TokenSet("foo");
ts.add(tok);
tss.add(ts);
assertEquals(ts, tss.getTokenSet(new Occurrence("foo", tok)));
assertTrue(tss.iterator().hasNext());
}
}