*** empty log message ***

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@572 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-31 16:36:38 +00:00
parent 2d2408d1cb
commit cac414bfa5

View File

@ -0,0 +1,43 @@
/*
* User: tom
* Date: Jul 31, 2002
* Time: 12:25:01 PM
*/
package test.net.sourceforge.pmd.cpd;
import junit.framework.TestCase;
import net.sourceforge.pmd.cpd.*;
import java.util.Iterator;
public class OccurrencesTest extends TestCase {
public OccurrencesTest(String name) {
super(name);
}
public void testBasic() {
Occurrences occs = new Occurrences();
assertTrue(!occs.contains(new Token('h', 0, "foo")));
assertTrue(!occs.getTiles().hasNext());
assertTrue(occs.isEmpty());
assertEquals(0, occs.size());
}
public void testInitialFrequencyCount() {
Occurrences occs = new Occurrences();
TokenSet ts = new TokenSet("foo");
ts.add(new Token('h', 0, "foo"));
ts.add(new Token('e', 1, "foo"));
ts.add(new Token('l', 2, "foo"));
ts.add(new Token('l', 3, "foo"));
ts.add(new Token('o', 4, "foo"));
occs.addInitial(ts);
assertEquals(4, occs.size());
assertTrue(occs.contains(new Token('h', 0, "foo")));
Iterator i = occs.getOccurrences(new Tile(new Token('h', 0, "foo")));
assertTrue(i.hasNext());
Occurrence occ = (Occurrence)i.next();
assertEquals("foo", occ.getTokenSetID());
assertEquals(0,occ.getIndex());
}
}