From cac414bfa59d70242af7604be2a223716cdcc2ae Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Wed, 31 Jul 2002 16:36:38 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@572 51baf565-9d33-0410-a72c-fc3788e3496d --- .../sourceforge/pmd/cpd/OccurrencesTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 pmd/regress/test/net/sourceforge/pmd/cpd/OccurrencesTest.java diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/OccurrencesTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/OccurrencesTest.java new file mode 100644 index 0000000000..75e7767676 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/OccurrencesTest.java @@ -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()); + } +}