diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetTest.java new file mode 100644 index 0000000000..ff89356970 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetTest.java @@ -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))); + } + + +} diff --git a/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetsTest.java b/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetsTest.java new file mode 100644 index 0000000000..309ba98178 --- /dev/null +++ b/pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetsTest.java @@ -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()); + } +}