From 4d0b843d65c6a27aefdebdb3acf79b228f302d22 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Wed, 31 Jul 2002 14:41:06 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@565 51baf565-9d33-0410-a72c-fc3788e3496d --- .../net/sourceforge/pmd/cpd/TokenSetTest.java | 48 +++++++++++++++++++ .../sourceforge/pmd/cpd/TokenSetsTest.java | 28 +++++++++++ 2 files changed, 76 insertions(+) create mode 100644 pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetTest.java create mode 100644 pmd/regress/test/net/sourceforge/pmd/cpd/TokenSetsTest.java 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()); + } +}